home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 2 / AACD 2.iso / AACD / Magazine / GraphicsCards / StormMesa / src / dlist.c < prev    next >
Encoding:
C/C++ Source or Header  |  1999-02-04  |  86.9 KB  |  3,675 lines

  1. /* $Id: dlist.c,v 3.8 1998/08/21 02:48:14 brianp Exp $ */
  2.  
  3. /*
  4.  * Mesa 3-D graphics library
  5.  * Version:  3.0
  6.  * Copyright (C) 1995-1998  Brian Paul
  7.  *
  8.  * This library is free software; you can redistribute it and/or
  9.  * modify it under the terms of the GNU Library General Public
  10.  * License as published by the Free Software Foundation; either
  11.  * version 2 of the License, or (at your option) any later version.
  12.  *
  13.  * This library is distributed in the hope that it will be useful,
  14.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  16.  * Library General Public License for more details.
  17.  *
  18.  * You should have received a copy of the GNU Library General Public
  19.  * License along with this library; if not, write to the Free
  20.  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  21.  */
  22.  
  23.  
  24. /*
  25.  * $Log: dlist.c,v $
  26.  * Revision 3.8  1998/08/21 02:48:14  brianp
  27.  * fixed polygon stipple pointer casting typo
  28.  *
  29.  * Revision 3.7  1998/08/21 02:42:21  brianp
  30.  * changed gl_save_PolygonStipple() param type to GLuint *
  31.  *
  32.  * Revision 3.6  1998/06/07 22:18:52  brianp
  33.  * implemented GL_EXT_multitexture extension
  34.  *
  35.  * Revision 3.5  1998/03/28 03:58:52  brianp
  36.  * fixed a few IRIX compiler warnings
  37.  *
  38.  * Revision 3.4  1998/03/27 03:39:14  brianp
  39.  * fixed G++ warnings
  40.  *
  41.  * Revision 3.3  1998/03/19 01:26:39  brianp
  42.  * fixed API pointer restore problem in glCallList(s)
  43.  *
  44.  * Revision 3.2  1998/02/20 04:50:09  brianp
  45.  * implemented GL_SGIS_multitexture
  46.  *
  47.  * Revision 3.1  1998/02/08 20:23:09  brianp
  48.  * removed const from gl_save_Bitmap()'s bitmap parameter
  49.  *
  50.  * Revision 3.0  1998/01/31 20:50:39  brianp
  51.  * initial rev
  52.  *
  53.  */
  54.  
  55.  
  56. #ifdef PC_HEADER
  57. #include "all.h"
  58. #else
  59. #include <assert.h>
  60. #include <stdio.h>
  61. #include <stdlib.h>
  62. #include <string.h>
  63. #include "accum.h"
  64. #include "alpha.h"
  65. #include "attrib.h"
  66. #include "bitmap.h"
  67. #include "blend.h"
  68. #include "clip.h"
  69. #include "colortab.h"
  70. #include "context.h"
  71. #include "copypix.h"
  72. #include "depth.h"
  73. #include "drawpix.h"
  74. #include "enable.h"
  75. #include "eval.h"
  76. #include "feedback.h"
  77. #include "fog.h"
  78. #include "hash.h"
  79. #include "image.h"
  80. #include "light.h"
  81. #include "lines.h"
  82. #include "dlist.h"
  83. #include "logic.h"
  84. #include "macros.h"
  85. #include "masking.h"
  86. #include "matrix.h"
  87. #include "misc.h"
  88. #include "pixel.h"
  89. #include "points.h"
  90. #include "polygon.h"
  91. #include "rastpos.h"
  92. #include "rect.h"
  93. #include "scissor.h"
  94. #include "stencil.h"
  95. #include "texobj.h"
  96. #include "teximage.h"
  97. #include "texstate.h"
  98. #include "types.h"
  99. #include "vb.h"
  100. #include "vbfill.h"
  101. #include "winpos.h"
  102. #endif
  103.  
  104.  
  105.  
  106. /*
  107. Functions which aren't compiled but executed immediately:
  108.     glIsList
  109.     glGenLists
  110.     glDeleteLists
  111.     glEndList
  112.     glFeedbackBuffer
  113.     glSelectBuffer
  114.     glRenderMode
  115.     glReadPixels
  116.     glPixelStore
  117.     glFlush
  118.     glFinish
  119.     glIsEnabled
  120.     glGet*
  121.  
  122. Functions which cause errors if called while compiling a display list:
  123.     glNewList
  124. */
  125.  
  126.  
  127.  
  128. /*
  129.  * Display list instructions are stored as sequences of "nodes".  Nodes
  130.  * are allocated in blocks.  Each block has BLOCK_SIZE nodes.  Blocks
  131.  * are linked together with a pointer.
  132.  */
  133.  
  134.  
  135. /* How many nodes to allocate at a time: */
  136. #define BLOCK_SIZE 500
  137.  
  138.  
  139. /*
  140.  * Display list opcodes.
  141.  *
  142.  * The fact that these identifiers are assigned consecutive
  143.  * integer values starting at 0 is very important, see InstSize array usage)
  144.  */
  145. typedef enum {
  146.     OPCODE_ACCUM,
  147.     OPCODE_ALPHA_FUNC,
  148.     OPCODE_BEGIN,
  149.     OPCODE_BIND_TEXTURE,
  150.     OPCODE_BITMAP,
  151.     OPCODE_BLEND_COLOR,
  152.     OPCODE_BLEND_EQUATION,
  153.     OPCODE_BLEND_FUNC,
  154.     OPCODE_CALL_LIST,
  155.     OPCODE_CALL_LIST_OFFSET,
  156.     OPCODE_CLEAR,
  157.     OPCODE_CLEAR_ACCUM,
  158.     OPCODE_CLEAR_COLOR,
  159.     OPCODE_CLEAR_DEPTH,
  160.     OPCODE_CLEAR_INDEX,
  161.     OPCODE_CLEAR_STENCIL,
  162.     OPCODE_CLIP_PLANE,
  163.     OPCODE_COLOR_3F,
  164.     OPCODE_COLOR_4F,
  165.     OPCODE_COLOR_4UB,
  166.     OPCODE_COLOR_MASK,
  167.     OPCODE_COLOR_MATERIAL,
  168.     OPCODE_COLOR_TABLE,
  169.     OPCODE_COLOR_SUB_TABLE,
  170.     OPCODE_COPY_PIXELS,
  171.     OPCODE_COPY_TEX_IMAGE1D,
  172.     OPCODE_COPY_TEX_IMAGE2D,
  173.     OPCODE_COPY_TEX_IMAGE3D,
  174.     OPCODE_COPY_TEX_SUB_IMAGE1D,
  175.     OPCODE_COPY_TEX_SUB_IMAGE2D,
  176.     OPCODE_COPY_TEX_SUB_IMAGE3D,
  177.     OPCODE_CULL_FACE,
  178.     OPCODE_DEPTH_FUNC,
  179.     OPCODE_DEPTH_MASK,
  180.     OPCODE_DEPTH_RANGE,
  181.     OPCODE_DISABLE,
  182.     OPCODE_DRAW_BUFFER,
  183.     OPCODE_DRAW_PIXELS,
  184.     OPCODE_EDGE_FLAG,
  185.     OPCODE_ENABLE,
  186.     OPCODE_END,
  187.     OPCODE_EVALCOORD1,
  188.     OPCODE_EVALCOORD2,
  189.     OPCODE_EVALMESH1,
  190.     OPCODE_EVALMESH2,
  191.     OPCODE_EVALPOINT1,
  192.     OPCODE_EVALPOINT2,
  193.     OPCODE_FOG,
  194.     OPCODE_FRONT_FACE,
  195.     OPCODE_FRUSTUM,
  196.     OPCODE_HINT,
  197.     OPCODE_INDEX,
  198.     OPCODE_INDEX_MASK,
  199.     OPCODE_INIT_NAMES,
  200.     OPCODE_LIGHT,
  201.     OPCODE_LIGHT_MODEL,
  202.     OPCODE_LINE_STIPPLE,
  203.     OPCODE_LINE_WIDTH,
  204.     OPCODE_LIST_BASE,
  205.     OPCODE_LOAD_IDENTITY,
  206.     OPCODE_LOAD_MATRIX,
  207.     OPCODE_LOAD_NAME,
  208.     OPCODE_LOGIC_OP,
  209.     OPCODE_MAP1,
  210.     OPCODE_MAP2,
  211.     OPCODE_MAPGRID1,
  212.     OPCODE_MAPGRID2,
  213.     OPCODE_MATERIAL,
  214.     OPCODE_MATRIX_MODE,
  215.     OPCODE_MULT_MATRIX,
  216.     OPCODE_MULTI_TEXCOORD4,
  217.     OPCODE_NORMAL,
  218.     OPCODE_ORTHO,
  219.     OPCODE_PASSTHROUGH,
  220.     OPCODE_PIXEL_MAP,
  221.     OPCODE_PIXEL_TRANSFER,
  222.     OPCODE_PIXEL_ZOOM,
  223.     OPCODE_POINT_SIZE,
  224.     OPCODE_POINT_PARAMETERS,
  225.     OPCODE_POLYGON_MODE,
  226.     OPCODE_POLYGON_STIPPLE,
  227.     OPCODE_POLYGON_OFFSET,
  228.     OPCODE_POP_ATTRIB,
  229.     OPCODE_POP_MATRIX,
  230.     OPCODE_POP_NAME,
  231.     OPCODE_PRIORITIZE_TEXTURE,
  232.     OPCODE_PUSH_ATTRIB,
  233.     OPCODE_PUSH_MATRIX,
  234.     OPCODE_PUSH_NAME,
  235.     OPCODE_RASTER_POS,
  236.     OPCODE_RECTF,
  237.     OPCODE_READ_BUFFER,
  238.     OPCODE_SCALE,
  239.     OPCODE_SCISSOR,
  240.     OPCODE_SELECT_TEXTURE_SGIS,
  241.     OPCODE_SELECT_TEXTURE,
  242.     OPCODE_SELECT_TEXTURE_COORD_SET,
  243.     OPCODE_SELECT_TEXTURE_TRANSFORM,
  244.     OPCODE_SHADE_MODEL,
  245.     OPCODE_STENCIL_FUNC,
  246.     OPCODE_STENCIL_MASK,
  247.     OPCODE_STENCIL_OP,
  248.     OPCODE_TEXCOORD2,
  249.     OPCODE_TEXCOORD4,
  250.     OPCODE_TEXENV,
  251.     OPCODE_TEXGEN,
  252.     OPCODE_TEXPARAMETER,
  253.     OPCODE_TEX_IMAGE1D,
  254.     OPCODE_TEX_IMAGE2D,
  255.     OPCODE_TEX_IMAGE3D,
  256.     OPCODE_TEX_SUB_IMAGE1D,
  257.     OPCODE_TEX_SUB_IMAGE2D,
  258.     OPCODE_TEX_SUB_IMAGE3D,
  259.     OPCODE_TRANSLATE,
  260.     OPCODE_VERTEX2,
  261.     OPCODE_VERTEX3,
  262.     OPCODE_VERTEX4,
  263.     OPCODE_VIEWPORT,
  264.     OPCODE_WINDOW_POS,
  265.     /* The following two are meta instructions */
  266.     OPCODE_CONTINUE,
  267.     OPCODE_END_OF_LIST
  268. } OpCode;
  269.  
  270.  
  271. /*
  272.  * Each instruction in the display list is stored as a sequence of
  273.  * contiguous nodes in memory.
  274.  * Each node is the union of a variety of datatypes.
  275.  */
  276. union node {
  277.     OpCode          opcode;
  278.     GLboolean       b;
  279.     GLbitfield      bf;
  280.     GLubyte         ub;
  281.     GLshort         s;
  282.     GLushort        us;
  283.     GLint           i;
  284.     GLuint          ui;
  285.     GLenum          e;
  286.     GLfloat         f;
  287.     GLvoid          *data;
  288.     void            *next;  /* If prev node's opcode==OPCODE_CONTINUE */
  289. };
  290.  
  291.  
  292.  
  293. /* Number of nodes of storage needed for each instruction: */
  294. static GLuint InstSize[ OPCODE_END_OF_LIST+1 ];
  295.  
  296.  
  297.  
  298. /**********************************************************************/
  299. /*****                           Private                          *****/
  300. /**********************************************************************/
  301.  
  302.  
  303. /*
  304.  * Allocate space for a display list instruction.
  305.  * Input:  opcode - type of instruction
  306.  *         argcount - number of arguments following the instruction
  307.  * Return: pointer to first node in the instruction
  308.  */
  309. static Node *alloc_instruction( GLcontext *ctx, OpCode opcode, GLint argcount )
  310. {
  311.    Node *n, *newblock;
  312.    GLuint count = InstSize[opcode];
  313.  
  314.    assert( (GLint) count == argcount+1 );
  315.  
  316.    if (ctx->CurrentPos + count + 2 > BLOCK_SIZE) {
  317.       /* This block is full.  Allocate a new block and chain to it */
  318.       n = ctx->CurrentBlock + ctx->CurrentPos;
  319.       n[0].opcode = OPCODE_CONTINUE;
  320.       newblock = (Node *) malloc( sizeof(Node) * BLOCK_SIZE );
  321.       if (!newblock) {
  322.      gl_error( ctx, GL_OUT_OF_MEMORY, "Building display list" );
  323.      return NULL;
  324.       }
  325.       n[1].next = (Node *) newblock;
  326.       ctx->CurrentBlock = newblock;
  327.       ctx->CurrentPos = 0;
  328.    }
  329.  
  330.    n = ctx->CurrentBlock + ctx->CurrentPos;
  331.    ctx->CurrentPos += count;
  332.  
  333.    n[0].opcode = opcode;
  334.  
  335.    return n;
  336. }
  337.  
  338.  
  339.  
  340. /*
  341.  * Make an empty display list.  This is used by glGenLists() to
  342.  * reserver display list IDs.
  343.  */
  344. static Node *make_empty_list( void )
  345. {
  346.    Node *n = (Node *) malloc( sizeof(Node) );
  347.    n[0].opcode = OPCODE_END_OF_LIST;
  348.    return n;
  349. }
  350.  
  351.  
  352.  
  353. /*
  354.  * Destroy all nodes in a display list.
  355.  * Input:  list - display list number
  356.  */
  357. void gl_destroy_list( GLcontext *ctx, GLuint list )
  358. {
  359.    Node *n, *block;
  360.    GLboolean done;
  361.  
  362.    block = (Node *) HashLookup(ctx->Shared->DisplayList, list);
  363.    n = block;
  364.  
  365.    done = block ? GL_FALSE : GL_TRUE;
  366.    while (!done) {
  367.       switch (n[0].opcode) {
  368.      /* special cases first */
  369.      case OPCODE_MAP1:
  370.         gl_free_control_points( ctx, n[1].e, (GLfloat *) n[6].data );
  371.         n += InstSize[n[0].opcode];
  372.         break;
  373.      case OPCODE_MAP2:
  374.         gl_free_control_points( ctx, n[1].e, (GLfloat *) n[10].data );
  375.         n += InstSize[n[0].opcode];
  376.         break;
  377.      case OPCODE_DRAW_PIXELS:
  378.         gl_free_image( (struct gl_image *) n[1].data );
  379.         n += InstSize[n[0].opcode];
  380.         break;
  381.      case OPCODE_BITMAP:
  382.         gl_free_image( (struct gl_image *) n[7].data );
  383.         n += InstSize[n[0].opcode];
  384.         break;
  385.      case OPCODE_COLOR_TABLE:
  386.         gl_free_image( (struct gl_image *) n[3].data );
  387.         n += InstSize[n[0].opcode];
  388.         break;
  389.      case OPCODE_COLOR_SUB_TABLE:
  390.         gl_free_image( (struct gl_image *) n[3].data );
  391.         n += InstSize[n[0].opcode];
  392.         break;
  393.      case OPCODE_POLYGON_STIPPLE:
  394.         free( n[1].data );
  395.         n += InstSize[n[0].opcode];
  396.         break;
  397.      case OPCODE_TEX_IMAGE1D:
  398.         gl_free_image( (struct gl_image *) n[8].data );
  399.         n += InstSize[n[0].opcode];
  400.         break;
  401.      case OPCODE_TEX_IMAGE2D:
  402.         gl_free_image( (struct gl_image *) n[9].data );
  403.         n += InstSize[n[0].opcode];
  404.         break;
  405.      case OPCODE_TEX_SUB_IMAGE1D:
  406.         {
  407.            struct gl_image *image;
  408.            image = (struct gl_image *) n[7].data;
  409.            gl_free_image( image );
  410.         }
  411.         break;
  412.      case OPCODE_TEX_SUB_IMAGE2D:
  413.         {
  414.            struct gl_image *image;
  415.            image = (struct gl_image *) n[9].data;
  416.            gl_free_image( image );
  417.         }
  418.         break;
  419.      case OPCODE_CONTINUE:
  420.         n = (Node *) n[1].next;
  421.         free( block );
  422.         block = n;
  423.         break;
  424.      case OPCODE_END_OF_LIST:
  425.         free( block );
  426.         done = GL_TRUE;
  427.         break;
  428.      default:
  429.         /* Most frequent case */
  430.         n += InstSize[n[0].opcode];
  431.         break;
  432.       }
  433.    }
  434.  
  435.    HashRemove(ctx->Shared->DisplayList, list);
  436. }
  437.  
  438.  
  439.  
  440. /*
  441.  * Translate the nth element of list from type to GLuint.
  442.  */
  443. static GLuint translate_id( GLsizei n, GLenum type, const GLvoid *list )
  444. {
  445.    GLbyte *bptr;
  446.    GLubyte *ubptr;
  447.    GLshort *sptr;
  448.    GLushort *usptr;
  449.    GLint *iptr;
  450.    GLuint *uiptr;
  451.    GLfloat *fptr;
  452.  
  453.    switch (type) {
  454.       case GL_BYTE:
  455.      bptr = (GLbyte *) list;
  456.      return (GLuint) *(bptr+n);
  457.       case GL_UNSIGNED_BYTE:
  458.      ubptr = (GLubyte *) list;
  459.      return (GLuint) *(ubptr+n);
  460.       case GL_SHORT:
  461.      sptr = (GLshort *) list;
  462.      return (GLuint) *(sptr+n);
  463.       case GL_UNSIGNED_SHORT:
  464.      usptr = (GLushort *) list;
  465.      return (GLuint) *(usptr+n);
  466.       case GL_INT:
  467.      iptr = (GLint *) list;
  468.      return (GLuint) *(iptr+n);
  469.       case GL_UNSIGNED_INT:
  470.      uiptr = (GLuint *) list;
  471.      return (GLuint) *(uiptr+n);
  472.       case GL_FLOAT:
  473.      fptr = (GLfloat *) list;
  474.      return (GLuint) *(fptr+n);
  475.       case GL_2_BYTES:
  476.      ubptr = ((GLubyte *) list) + 2*n;
  477.      return (GLuint) *ubptr * 256 + (GLuint) *(ubptr+1);
  478.       case GL_3_BYTES:
  479.      ubptr = ((GLubyte *) list) + 3*n;
  480.      return (GLuint) *ubptr * 65536
  481.           + (GLuint) *(ubptr+1) * 256
  482.           + (GLuint) *(ubptr+2);
  483.       case GL_4_BYTES:
  484.      ubptr = ((GLubyte *) list) + 4*n;
  485.      return (GLuint) *ubptr * 16777216
  486.           + (GLuint) *(ubptr+1) * 65536
  487.           + (GLuint) *(ubptr+2) * 256
  488.           + (GLuint) *(ubptr+3);
  489.       default:
  490.      return 0;
  491.    }
  492. }
  493.  
  494.  
  495.  
  496.  
  497. /**********************************************************************/
  498. /*****                        Public                              *****/
  499. /**********************************************************************/
  500.  
  501. void gl_init_lists( void )
  502. {
  503.    static int init_flag = 0;
  504.  
  505.    if (init_flag==0) {
  506.       InstSize[OPCODE_ACCUM] = 3;
  507.       InstSize[OPCODE_ALPHA_FUNC] = 3;
  508.       InstSize[OPCODE_BEGIN] = 2;
  509.       InstSize[OPCODE_BIND_TEXTURE] = 3;
  510.       InstSize[OPCODE_BITMAP] = 8;
  511.       InstSize[OPCODE_BLEND_COLOR] = 5;
  512.       InstSize[OPCODE_BLEND_EQUATION] = 2;
  513.       InstSize[OPCODE_BLEND_FUNC] = 3;
  514.       InstSize[OPCODE_CALL_LIST] = 2;
  515.       InstSize[OPCODE_CALL_LIST_OFFSET] = 2;
  516.       InstSize[OPCODE_CLEAR] = 2;
  517.       InstSize[OPCODE_CLEAR_ACCUM] = 5;
  518.       InstSize[OPCODE_CLEAR_COLOR] = 5;
  519.       InstSize[OPCODE_CLEAR_DEPTH] = 2;
  520.       InstSize[OPCODE_CLEAR_INDEX] = 2;
  521.       InstSize[OPCODE_CLEAR_STENCIL] = 2;
  522.       InstSize[OPCODE_CLIP_PLANE] = 6;
  523.       InstSize[OPCODE_COLOR_3F] = 4;
  524.       InstSize[OPCODE_COLOR_4F] = 5;
  525.       InstSize[OPCODE_COLOR_4UB] = 5;
  526.       InstSize[OPCODE_COLOR_MASK] = 5;
  527.       InstSize[OPCODE_COLOR_MATERIAL] = 3;
  528.       InstSize[OPCODE_COLOR_TABLE] = 4;
  529.       InstSize[OPCODE_COLOR_SUB_TABLE] = 4;
  530.       InstSize[OPCODE_COPY_PIXELS] = 6;
  531.       InstSize[OPCODE_COPY_TEX_IMAGE1D] = 8;
  532.       InstSize[OPCODE_COPY_TEX_IMAGE2D] = 9;
  533.       InstSize[OPCODE_COPY_TEX_SUB_IMAGE1D] = 7;
  534.       InstSize[OPCODE_COPY_TEX_SUB_IMAGE2D] = 9;
  535.       InstSize[OPCODE_COPY_TEX_SUB_IMAGE3D] = 10;
  536.       InstSize[OPCODE_CULL_FACE] = 2;
  537.       InstSize[OPCODE_DEPTH_FUNC] = 2;
  538.       InstSize[OPCODE_DEPTH_MASK] = 2;
  539.       InstSize[OPCODE_DEPTH_RANGE] = 3;
  540.       InstSize[OPCODE_DISABLE] = 2;
  541.       InstSize[OPCODE_DRAW_BUFFER] = 2;
  542.       InstSize[OPCODE_DRAW_PIXELS] = 2;
  543.       InstSize[OPCODE_ENABLE] = 2;
  544.       InstSize[OPCODE_EDGE_FLAG] = 2;
  545.       InstSize[OPCODE_END] = 1;
  546.       InstSize[OPCODE_EVALCOORD1] = 2;
  547.       InstSize[OPCODE_EVALCOORD2] = 3;
  548.       InstSize[OPCODE_EVALMESH1] = 4;
  549.       InstSize[OPCODE_EVALMESH2] = 6;
  550.       InstSize[OPCODE_EVALPOINT1] = 2;
  551.       InstSize[OPCODE_EVALPOINT2] = 3;
  552.       InstSize[OPCODE_FOG] = 6;
  553.       InstSize[OPCODE_FRONT_FACE] = 2;
  554.       InstSize[OPCODE_FRUSTUM] = 7;
  555.       InstSize[OPCODE_HINT] = 3;
  556.       InstSize[OPCODE_INDEX] = 2;
  557.       InstSize[OPCODE_INDEX_MASK] = 2;
  558.       InstSize[OPCODE_INIT_NAMES] = 1;
  559.       InstSize[OPCODE_LIGHT] = 7;
  560.       InstSize[OPCODE_LIGHT_MODEL] = 6;
  561.       InstSize[OPCODE_LINE_STIPPLE] = 3;
  562.       InstSize[OPCODE_LINE_WIDTH] = 2;
  563.       InstSize[OPCODE_LIST_BASE] = 2;
  564.       InstSize[OPCODE_LOAD_IDENTITY] = 1;
  565.       InstSize[OPCODE_LOAD_MATRIX] = 17;
  566.       InstSize[OPCODE_LOAD_NAME] = 2;
  567.       InstSize[OPCODE_LOGIC_OP] = 2;
  568.       InstSize[OPCODE_MAP1] = 7;
  569.       InstSize[OPCODE_MAP2] = 11;
  570.       InstSize[OPCODE_MAPGRID1] = 4;
  571.       InstSize[OPCODE_MAPGRID2] = 7;
  572.       InstSize[OPCODE_MATERIAL] = 7;
  573.       InstSize[OPCODE_MATRIX_MODE] = 2;
  574.       InstSize[OPCODE_MULT_MATRIX] = 17;
  575.       InstSize[OPCODE_MULTI_TEXCOORD4] = 6;
  576.       InstSize[OPCODE_NORMAL] = 4;
  577.       InstSize[OPCODE_ORTHO] = 7;
  578.       InstSize[OPCODE_PASSTHROUGH] = 2;
  579.       InstSize[OPCODE_PIXEL_MAP] = 4;
  580.       InstSize[OPCODE_PIXEL_TRANSFER] = 3;
  581.       InstSize[OPCODE_PIXEL_ZOOM] = 3;
  582.       InstSize[OPCODE_POINT_SIZE] = 2;
  583.       InstSize[OPCODE_POINT_PARAMETERS] = 5;
  584.       InstSize[OPCODE_POLYGON_MODE] = 3;
  585.       InstSize[OPCODE_POLYGON_STIPPLE] = 2;
  586.       InstSize[OPCODE_POLYGON_OFFSET] = 3;
  587.       InstSize[OPCODE_POP_ATTRIB] = 1;
  588.       InstSize[OPCODE_POP_MATRIX] = 1;
  589.       InstSize[OPCODE_POP_NAME] = 1;
  590.       InstSize[OPCODE_PRIORITIZE_TEXTURE] = 3;
  591.       InstSize[OPCODE_PUSH_ATTRIB] = 2;
  592.       InstSize[OPCODE_PUSH_MATRIX] = 1;
  593.       InstSize[OPCODE_PUSH_NAME] = 2;
  594.       InstSize[OPCODE_RASTER_POS] = 5;
  595.       InstSize[OPCODE_RECTF] = 5;
  596.       InstSize[OPCODE_READ_BUFFER] = 2;
  597.       InstSize[OPCODE_SCALE] = 4;
  598.       InstSize[OPCODE_SCISSOR] = 5;
  599.       InstSize[OPCODE_SELECT_TEXTURE_SGIS] = 2;
  600.       InstSize[OPCODE_SELECT_TEXTURE] = 2;
  601.       InstSize[OPCODE_SELECT_TEXTURE_COORD_SET] = 2;
  602.       InstSize[OPCODE_SELECT_TEXTURE_TRANSFORM] = 2;
  603.       InstSize[OPCODE_STENCIL_FUNC] = 4;
  604.       InstSize[OPCODE_STENCIL_MASK] = 2;
  605.       InstSize[OPCODE_STENCIL_OP] = 4;
  606.       InstSize[OPCODE_SHADE_MODEL] = 2;
  607.       InstSize[OPCODE_TEXCOORD2] = 3;
  608.       InstSize[OPCODE_TEXCOORD4] = 5;
  609.       InstSize[OPCODE_TEXENV] = 7;
  610.       InstSize[OPCODE_TEXGEN] = 7;
  611.       InstSize[OPCODE_TEXPARAMETER] = 7;
  612.       InstSize[OPCODE_TEX_IMAGE1D] = 9;
  613.       InstSize[OPCODE_TEX_IMAGE2D] = 10;
  614.       InstSize[OPCODE_TEX_IMAGE3D] = 11;
  615.       InstSize[OPCODE_TEX_SUB_IMAGE1D] = 8;
  616.       InstSize[OPCODE_TEX_SUB_IMAGE2D] = 10;
  617.       InstSize[OPCODE_TEX_SUB_IMAGE3D] = 12;
  618.       InstSize[OPCODE_TRANSLATE] = 4;
  619.       InstSize[OPCODE_VERTEX2] = 3;
  620.       InstSize[OPCODE_VERTEX3] = 4;
  621.       InstSize[OPCODE_VERTEX4] = 5;
  622.       InstSize[OPCODE_VIEWPORT] = 5;
  623.       InstSize[OPCODE_WINDOW_POS] = 5;
  624.       InstSize[OPCODE_CONTINUE] = 2;
  625.       InstSize[OPCODE_END_OF_LIST] = 1;
  626.    }
  627.    init_flag = 1;
  628. }
  629.  
  630.  
  631. /*
  632.  * Display List compilation functions
  633.  */
  634.  
  635.  
  636. void gl_save_Accum( GLcontext *ctx, GLenum op, GLfloat value )
  637. {
  638.    Node *n = alloc_instruction( ctx, OPCODE_ACCUM, 2 );
  639.    if (n) {
  640.       n[1].e = op;
  641.       n[2].f = value;
  642.    }
  643.    if (ctx->ExecuteFlag) {
  644.       (*ctx->Exec.Accum)( ctx, op, value );
  645.    }
  646. }
  647.  
  648.  
  649. void gl_save_AlphaFunc( GLcontext *ctx, GLenum func, GLclampf ref )
  650. {
  651.    Node *n = alloc_instruction( ctx, OPCODE_ALPHA_FUNC, 2 );
  652.    if (n) {
  653.       n[1].e = func;
  654.       n[2].f = (GLfloat) ref;
  655.    }
  656.    if (ctx->ExecuteFlag) {
  657.       (*ctx->Exec.AlphaFunc)( ctx, func, ref );
  658.    }
  659. }
  660.  
  661.  
  662. void gl_save_Begin( GLcontext *ctx, GLenum mode )
  663. {
  664.    Node *n = alloc_instruction( ctx, OPCODE_BEGIN, 1 );
  665.    if (n) {
  666.       n[1].e = mode;
  667.    }
  668.    if (ctx->ExecuteFlag) {
  669.       (*ctx->Exec.Begin)( ctx, mode );
  670.    }
  671. }
  672.  
  673.  
  674. void gl_save_BindTexture( GLcontext *ctx, GLenum target, GLuint texture )
  675. {
  676.    Node *n = alloc_instruction( ctx, OPCODE_BIND_TEXTURE, 2 );
  677.    if (n) {
  678.       n[1].e = target;
  679.       n[2].ui = texture;
  680.    }
  681.    if (ctx->ExecuteFlag) {
  682.       (*ctx->Exec.BindTexture)( ctx, target, texture );
  683.    }
  684. }
  685.  
  686.  
  687. void gl_save_Bitmap( GLcontext *ctx,
  688.              GLsizei width, GLsizei height,
  689.              GLfloat xorig, GLfloat yorig,
  690.              GLfloat xmove, GLfloat ymove,
  691.              struct gl_image *bitmap )
  692. {
  693.    Node *n = alloc_instruction( ctx, OPCODE_BITMAP, 7 );
  694.    if (n) {
  695.       n[1].i = (GLint) width;
  696.       n[2].i = (GLint) height;
  697.       n[3].f = xorig;
  698.       n[4].f = yorig;
  699.       n[5].f = xmove;
  700.       n[6].f = ymove;
  701.       n[7].data = (void *) bitmap;
  702.    }
  703.    if (bitmap) {
  704.       bitmap->RefCount = 1;
  705.    }
  706.    if (ctx->ExecuteFlag) {
  707.       (*ctx->Exec.Bitmap)( ctx, width, height,
  708.             xorig, yorig, xmove, ymove, bitmap );
  709.    }
  710. }
  711.  
  712.  
  713. void gl_save_BlendEquation( GLcontext *ctx, GLenum mode )
  714. {
  715.    Node *n = alloc_instruction( ctx, OPCODE_BLEND_EQUATION, 1 );
  716.    if (n) {
  717.       n[1].e = mode;
  718.    }
  719.    if (ctx->ExecuteFlag) {
  720.       (*ctx->Exec.BlendEquation)( ctx, mode );
  721.    }
  722. }
  723.  
  724.  
  725. void gl_save_BlendFunc( GLcontext *ctx, GLenum sfactor, GLenum dfactor )
  726. {
  727.    Node *n = alloc_instruction( ctx, OPCODE_BLEND_FUNC, 2 );
  728.    if (n) {
  729.       n[1].e = sfactor;
  730.       n[2].e = dfactor;
  731.    }
  732.    if (ctx->ExecuteFlag) {
  733.       (*ctx->Exec.BlendFunc)( ctx, sfactor, dfactor );
  734.    }
  735. }
  736.  
  737.  
  738. void gl_save_BlendColor( GLcontext *ctx, GLfloat red, GLfloat green,
  739.              GLfloat blue, GLfloat alpha )
  740. {
  741.    Node *n = alloc_instruction( ctx, OPCODE_BLEND_COLOR, 4 );
  742.    if (n) {
  743.       n[1].f = red;
  744.       n[2].f = green;
  745.       n[3].f = blue;
  746.       n[4].f = alpha;
  747.    }
  748.    if (ctx->ExecuteFlag) {
  749.       (*ctx->Exec.BlendColor)( ctx, red, green, blue, alpha );
  750.    }
  751. }
  752.  
  753.  
  754. void gl_save_CallList( GLcontext *ctx, GLuint list )
  755. {
  756.    Node *n = alloc_instruction( ctx, OPCODE_CALL_LIST, 1 );
  757.    if (n) {
  758.       n[1].ui = list;
  759.    }
  760.    if (ctx->ExecuteFlag) {
  761.       (*ctx->Exec.CallList)( ctx, list );
  762.    }
  763. }
  764.  
  765.  
  766. void gl_save_CallLists( GLcontext *ctx,
  767.             GLsizei n, GLenum type, const GLvoid *lists )
  768. {
  769.    GLint i;
  770.  
  771.    for (i=0;i<n;i++) {
  772.       GLuint list = translate_id( i, type, lists );
  773.       Node *n = alloc_instruction( ctx, OPCODE_CALL_LIST_OFFSET, 1 );
  774.       if (n) {
  775.      n[1].ui = list;
  776.       }
  777.    }
  778.    if (ctx->ExecuteFlag) {
  779.       (*ctx->Exec.CallLists)( ctx, n, type, lists );
  780.    }
  781. }
  782.  
  783.  
  784. void gl_save_Clear( GLcontext *ctx, GLbitfield mask )
  785. {
  786.    Node *n = alloc_instruction( ctx, OPCODE_CLEAR, 1 );
  787.    if (n) {
  788.       n[1].bf = mask;
  789.    }
  790.    if (ctx->ExecuteFlag) {
  791.       (*ctx->Exec.Clear)( ctx, mask );
  792.    }
  793. }
  794.  
  795.  
  796. void gl_save_ClearAccum( GLcontext *ctx, GLfloat red, GLfloat green,
  797.              GLfloat blue, GLfloat alpha )
  798. {
  799.    Node *n = alloc_instruction( ctx, OPCODE_CLEAR_ACCUM, 4 );
  800.    if (n) {
  801.       n[1].f = red;
  802.       n[2].f = green;
  803.       n[3].f = blue;
  804.       n[4].f = alpha;
  805.    }
  806.    if (ctx->ExecuteFlag) {
  807.       (*ctx->Exec.ClearAccum)( ctx, red, green, blue, alpha );
  808.    }
  809. }
  810.  
  811.  
  812. void gl_save_ClearColor( GLcontext *ctx, GLclampf red, GLclampf green,
  813.              GLclampf blue, GLclampf alpha )
  814. {
  815.    Node *n = alloc_instruction( ctx, OPCODE_CLEAR_COLOR, 4 );
  816.    if (n) {
  817.       n[1].f = red;
  818.       n[2].f = green;
  819.       n[3].f = blue;
  820.       n[4].f = alpha;
  821.    }
  822.    if (ctx->ExecuteFlag) {
  823.       (*ctx->Exec.ClearColor)( ctx, red, green, blue, alpha );
  824.    }
  825. }
  826.  
  827.  
  828. void gl_save_ClearDepth( GLcontext *ctx, GLclampd depth )
  829. {
  830.    Node *n = alloc_instruction( ctx, OPCODE_CLEAR_DEPTH, 1 );
  831.    if (n) {
  832.       n[1].f = (GLfloat) depth;
  833.    }
  834.    if (ctx->ExecuteFlag) {
  835.       (*ctx->Exec.ClearDepth)( ctx, depth );
  836.    }
  837. }
  838.  
  839.  
  840. void gl_save_ClearIndex( GLcontext *ctx, GLfloat c )
  841. {
  842.    Node *n = alloc_instruction( ctx, OPCODE_CLEAR_INDEX, 1 );
  843.    if (n) {
  844.       n[1].f = c;
  845.    }
  846.    if (ctx->ExecuteFlag) {
  847.       (*ctx->Exec.ClearIndex)( ctx, c );
  848.    }
  849. }
  850.  
  851.  
  852. void gl_save_ClearStencil( GLcontext *ctx, GLint s )
  853. {
  854.    Node *n = alloc_instruction( ctx, OPCODE_CLEAR_STENCIL, 1 );
  855.    if (n) {
  856.       n[1].i = s;
  857.    }
  858.    if (ctx->ExecuteFlag) {
  859.       (*ctx->Exec.ClearStencil)( ctx, s );
  860.    }
  861. }
  862.  
  863.  
  864. void gl_save_ClipPlane( GLcontext *ctx, GLenum plane, const GLfloat *equ )
  865. {
  866.    Node *n = alloc_instruction( ctx, OPCODE_CLIP_PLANE, 5 );
  867.    if (n) {
  868.       n[1].e = plane;
  869.       n[2].f = equ[0];
  870.       n[3].f = equ[1];
  871.       n[4].f = equ[2];
  872.       n[5].f = equ[3];
  873.    }
  874.    if (ctx->ExecuteFlag) {
  875.       (*ctx->Exec.ClipPlane)( ctx, plane, equ );
  876.    }
  877. }
  878.  
  879.  
  880. void gl_save_Color3f( GLcontext *ctx, GLfloat r, GLfloat g, GLfloat b )
  881. {
  882.    Node *n = alloc_instruction( ctx, OPCODE_COLOR_3F, 3 );
  883.    if (n) {
  884.       n[1].f = r;
  885.       n[2].f = g;
  886.       n[3].f = b;
  887.    }
  888.    if (ctx->ExecuteFlag) {
  889.       (*ctx->Exec.Color3f)( ctx, r, g, b );
  890.    }
  891. }
  892.  
  893.  
  894. void gl_save_Color3fv( GLcontext *ctx, const GLfloat *c )
  895. {
  896.    Node *n = alloc_instruction( ctx, OPCODE_COLOR_3F, 3 );
  897.    if (n) {
  898.       n[1].f = c[0];
  899.       n[2].f = c[1];
  900.       n[3].f = c[2];
  901.    }
  902.    if (ctx->ExecuteFlag) {
  903.       (*ctx->Exec.Color3fv)( ctx, c );
  904.    }
  905. }
  906.  
  907.  
  908. void gl_save_Color4f( GLcontext *ctx, GLfloat r, GLfloat g,
  909.                       GLfloat b, GLfloat a )
  910. {
  911.    Node *n = alloc_instruction( ctx, OPCODE_COLOR_4F, 4 );
  912.    if (n) {
  913.       n[1].f = r;
  914.       n[2].f = g;
  915.       n[3].f = b;
  916.       n[4].f = a;
  917.    }
  918.    if (ctx->ExecuteFlag) {
  919.       (*ctx->Exec.Color4f)( ctx, r, g, b, a );
  920.    }
  921. }
  922.  
  923.  
  924. void gl_save_Color4fv( GLcontext *ctx, const GLfloat *c )
  925. {
  926.    Node *n = alloc_instruction( ctx, OPCODE_COLOR_4F, 4 );
  927.    if (n) {
  928.       n[1].f = c[0];
  929.       n[2].f = c[1];
  930.       n[3].f = c[2];
  931.       n[4].f = c[3];
  932.    }
  933.    if (ctx->ExecuteFlag) {
  934.       (*ctx->Exec.Color4fv)( ctx, c );
  935.    }
  936. }
  937.  
  938.  
  939. void gl_save_Color4ub( GLcontext *ctx, GLubyte r, GLubyte g,
  940.                        GLubyte b, GLubyte a )
  941. {
  942.    Node *n = alloc_instruction( ctx, OPCODE_COLOR_4UB, 4 );
  943.    if (n) {
  944.       n[1].ub = r;
  945.       n[2].ub = g;
  946.       n[3].ub = b;
  947.       n[4].ub = a;
  948.    }
  949.    if (ctx->ExecuteFlag) {
  950.       (*ctx->Exec.Color4ub)( ctx, r, g, b, a );
  951.    }
  952. }
  953.  
  954.  
  955. void gl_save_Color4ubv( GLcontext *ctx, const GLubyte *c )
  956. {
  957.    Node *n = alloc_instruction( ctx, OPCODE_COLOR_4UB, 4 );
  958.    if (n) {
  959.       n[1].ub = c[0];
  960.       n[2].ub = c[1];
  961.       n[3].ub = c[2];
  962.       n[4].ub = c[3];
  963.    }
  964.    if (ctx->ExecuteFlag) {
  965.       (*ctx->Exec.Color4ubv)( ctx, c );
  966.    }
  967. }
  968.  
  969.  
  970. void gl_save_ColorMask( GLcontext *ctx, GLboolean red, GLboolean green,
  971.             GLboolean blue, GLboolean alpha )
  972. {
  973.    Node *n = alloc_instruction( ctx, OPCODE_COLOR_MASK, 4 );
  974.    if (n) {
  975.       n[1].b = red;
  976.       n[2].b = green;
  977.       n[3].b = blue;
  978.       n[4].b = alpha;
  979.    }
  980.    if (ctx->ExecuteFlag) {
  981.       (*ctx->Exec.ColorMask)( ctx, red, green, blue, alpha );
  982.    }
  983. }
  984.  
  985.  
  986. void gl_save_ColorMaterial( GLcontext *ctx, GLenum face, GLenum mode )
  987. {
  988.    Node *n = alloc_instruction( ctx, OPCODE_COLOR_MATERIAL, 2 );
  989.    if (n) {
  990.       n[1].e = face;
  991.       n[2].e = mode;
  992.    }
  993.    if (ctx->ExecuteFlag) {
  994.       (*ctx->Exec.ColorMaterial)( ctx, face, mode );
  995.    }
  996. }
  997.  
  998.  
  999. void gl_save_ColorTable( GLcontext *ctx, GLenum target, GLenum internalFormat,
  1000.              struct gl_image *table )
  1001. {
  1002.    Node *n = alloc_instruction( ctx, OPCODE_COLOR_TABLE, 3 );
  1003.    if (n) {
  1004.       n[1].e = target;
  1005.       n[2].e = internalFormat;
  1006.       n[3].data = (GLvoid *) table;
  1007.       if (table) {
  1008.      /* must retain this image */
  1009.      table->RefCount = 1;
  1010.       }
  1011.    }
  1012.    if (ctx->ExecuteFlag) {
  1013.       (*ctx->Exec.ColorTable)( ctx, target, internalFormat, table );
  1014.    }
  1015. }
  1016.  
  1017.  
  1018. void gl_save_ColorSubTable( GLcontext *ctx, GLenum target,
  1019.                 GLsizei start, struct gl_image *data )
  1020. {
  1021.    Node *n = alloc_instruction( ctx, OPCODE_COLOR_SUB_TABLE, 3 );
  1022.    if (n) {
  1023.       n[1].e = target;
  1024.       n[2].i = start;
  1025.       n[3].data = (GLvoid *) data;
  1026.       if (data) {
  1027.      /* must retain this image */
  1028.      data->RefCount = 1;
  1029.       }
  1030.    }
  1031.    if (ctx->ExecuteFlag) {
  1032.       (*ctx->Exec.ColorSubTable)( ctx, target, start, data );
  1033.    }
  1034. }
  1035.  
  1036.  
  1037.  
  1038. void gl_save_CopyPixels( GLcontext *ctx, GLint x, GLint y,
  1039.              GLsizei width, GLsizei height, GLenum type )
  1040. {
  1041.    Node *n = alloc_instruction( ctx, OPCODE_COPY_PIXELS, 5 );
  1042.    if (n) {
  1043.       n[1].i = x;
  1044.       n[2].i = y;
  1045.       n[3].i = (GLint) width;
  1046.       n[4].i = (GLint) height;
  1047.       n[5].e = type;
  1048.    }
  1049.    if (ctx->ExecuteFlag) {
  1050.       (*ctx->Exec.CopyPixels)( ctx, x, y, width, height, type );
  1051.    }
  1052. }
  1053.  
  1054.  
  1055.  
  1056. void gl_save_CopyTexImage1D( GLcontext *ctx,
  1057.                  GLenum target, GLint level,
  1058.                  GLenum internalformat,
  1059.                  GLint x, GLint y, GLsizei width,
  1060.                  GLint border )
  1061. {
  1062.    Node *n = alloc_instruction( ctx, OPCODE_COPY_TEX_IMAGE1D, 7 );
  1063.    if (n) {
  1064.       n[1].e = target;
  1065.       n[2].i = level;
  1066.       n[3].e = internalformat;
  1067.       n[4].i = x;
  1068.       n[5].i = y;
  1069.       n[6].i = width;
  1070.       n[7].i = border;
  1071.    }
  1072.    if (ctx->ExecuteFlag) {
  1073.       (*ctx->Exec.CopyTexImage1D)( ctx, target, level, internalformat,
  1074.                 x, y, width, border );
  1075.    }
  1076. }
  1077.  
  1078.  
  1079. void gl_save_CopyTexImage2D( GLcontext *ctx,
  1080.                  GLenum target, GLint level,
  1081.                  GLenum internalformat,
  1082.                  GLint x, GLint y, GLsizei width,
  1083.                  GLsizei height, GLint border )
  1084. {
  1085.    Node *n = alloc_instruction( ctx, OPCODE_COPY_TEX_IMAGE2D, 8 );
  1086.    if (n) {
  1087.       n[1].e = target;
  1088.       n[2].i = level;
  1089.       n[3].e = internalformat;
  1090.       n[4].i = x;
  1091.       n[5].i = y;
  1092.       n[6].i = width;
  1093.       n[7].i = height;
  1094.       n[8].i = border;
  1095.    }
  1096.    if (ctx->ExecuteFlag) {
  1097.       (*ctx->Exec.CopyTexImage2D)( ctx, target, level, internalformat,
  1098.                 x, y, width, height, border );
  1099.    }
  1100. }
  1101.  
  1102.  
  1103.  
  1104. void gl_save_CopyTexSubImage1D( GLcontext *ctx,
  1105.                 GLenum target, GLint level,
  1106.                 GLint xoffset, GLint x, GLint y,
  1107.                 GLsizei width )
  1108. {
  1109.    Node *n = alloc_instruction( ctx, OPCODE_COPY_TEX_SUB_IMAGE1D, 6 );
  1110.    if (n) {
  1111.       n[1].e = target;
  1112.       n[2].i = level;
  1113.       n[3].i = xoffset;
  1114.       n[4].i = x;
  1115.       n[5].i = y;
  1116.       n[6].i = width;
  1117.    }
  1118.    if (ctx->ExecuteFlag) {
  1119.       (*ctx->Exec.CopyTexSubImage1D)( ctx, target, level, xoffset, x, y, width );
  1120.    }
  1121. }
  1122.  
  1123.  
  1124. void gl_save_CopyTexSubImage2D( GLcontext *ctx,
  1125.                 GLenum target, GLint level,
  1126.                 GLint xoffset, GLint yoffset,
  1127.                 GLint x, GLint y,
  1128.                 GLsizei width, GLint height )
  1129. {
  1130.    Node *n = alloc_instruction( ctx, OPCODE_COPY_TEX_SUB_IMAGE2D, 8 );
  1131.    if (n) {
  1132.       n[1].e = target;
  1133.       n[2].i = level;
  1134.       n[3].i = xoffset;
  1135.       n[4].i = yoffset;
  1136.       n[5].i = x;
  1137.       n[6].i = y;
  1138.       n[7].i = width;
  1139.       n[8].i = height;
  1140.    }
  1141.    if (ctx->ExecuteFlag) {
  1142.       (*ctx->Exec.CopyTexSubImage2D)( ctx, target, level, xoffset, yoffset,
  1143.                    x, y, width, height );
  1144.    }
  1145. }
  1146.  
  1147.  
  1148. void gl_save_CopyTexSubImage3DEXT( GLcontext *ctx,
  1149.                    GLenum target, GLint level,
  1150.                    GLint xoffset, GLint yoffset, GLint zoffset,
  1151.                    GLint x, GLint y,
  1152.                    GLsizei width, GLint height )
  1153. {
  1154.    Node *n = alloc_instruction( ctx, OPCODE_COPY_TEX_SUB_IMAGE3D, 9 );
  1155.    if (n) {
  1156.       n[1].e = target;
  1157.       n[2].i = level;
  1158.       n[3].i = xoffset;
  1159.       n[4].i = yoffset;
  1160.       n[5].i = zoffset;
  1161.       n[6].i = x;
  1162.       n[7].i = y;
  1163.       n[8].i = width;
  1164.       n[9].i = height;
  1165.    }
  1166.    if (ctx->ExecuteFlag) {
  1167.       (*ctx->Exec.CopyTexSubImage3DEXT)( ctx, target, level, xoffset, yoffset, zoffset,
  1168.                    x, y, width, height );
  1169.    }
  1170. }
  1171.  
  1172.  
  1173. void gl_save_CullFace( GLcontext *ctx, GLenum mode )
  1174. {
  1175.    Node *n = alloc_instruction( ctx, OPCODE_CULL_FACE, 1 );
  1176.    if (n) {
  1177.       n[1].e = mode;
  1178.    }
  1179.    if (ctx->ExecuteFlag) {
  1180.       (*ctx->Exec.CullFace)( ctx, mode );
  1181.    }
  1182. }
  1183.  
  1184.  
  1185. void gl_save_DepthFunc( GLcontext *ctx, GLenum func )
  1186. {
  1187.    Node *n = alloc_instruction( ctx, OPCODE_DEPTH_FUNC, 1 );
  1188.    if (n) {
  1189.       n[1].e = func;
  1190.    }
  1191.    if (ctx->ExecuteFlag) {
  1192.       (*ctx->Exec.DepthFunc)( ctx, func );
  1193.    }
  1194. }
  1195.  
  1196.  
  1197. void gl_save_DepthMask( GLcontext *ctx, GLboolean mask )
  1198. {
  1199.    Node *n = alloc_instruction( ctx, OPCODE_DEPTH_MASK, 1 );
  1200.    if (n) {
  1201.       n[1].b = mask;
  1202.    }
  1203.    if (ctx->ExecuteFlag) {
  1204.       (*ctx->Exec.DepthMask)( ctx, mask );
  1205.    }
  1206. }
  1207.  
  1208.  
  1209. void gl_save_DepthRange( GLcontext *ctx, GLclampd nearval, GLclampd farval )
  1210. {
  1211.    Node *n = alloc_instruction( ctx, OPCODE_DEPTH_RANGE, 2 );
  1212.    if (n) {
  1213.       n[1].f = (GLfloat) nearval;
  1214.       n[2].f = (GLfloat) farval;
  1215.    }
  1216.    if (ctx->ExecuteFlag) {
  1217.       (*ctx->Exec.DepthRange)( ctx, nearval, farval );
  1218.    }
  1219. }
  1220.  
  1221.  
  1222. void gl_save_Disable( GLcontext *ctx, GLenum cap )
  1223. {
  1224.    Node *n = alloc_instruction( ctx, OPCODE_DISABLE, 1 );
  1225.    if (n) {
  1226.       n[1].e = cap;
  1227.    }
  1228.    if (ctx->ExecuteFlag) {
  1229.       (*ctx->Exec.Disable)( ctx, cap );
  1230.    }
  1231. }
  1232.  
  1233.  
  1234. void gl_save_DrawBuffer( GLcontext *ctx, GLenum mode )
  1235. {
  1236.    Node *n = alloc_instruction( ctx, OPCODE_DRAW_BUFFER, 1 );
  1237.    if (n) {
  1238.       n[1].e = mode;
  1239.    }
  1240.    if (ctx->ExecuteFlag) {
  1241.       (*ctx->Exec.DrawBuffer)( ctx, mode );
  1242.    }
  1243. }
  1244.  
  1245.  
  1246. void gl_save_DrawPixels( GLcontext *ctx, struct gl_image *image )
  1247. {
  1248.    Node *n = alloc_instruction( ctx, OPCODE_DRAW_PIXELS, 1 );
  1249.    if (n) {
  1250.       n[1].data = (GLvoid *) image;
  1251.    }
  1252.    if (image) {
  1253.       image->RefCount = 1;
  1254.    }
  1255.    if (ctx->ExecuteFlag) {
  1256.       (*ctx->Exec.DrawPixels)( ctx, image );
  1257.    }
  1258. }
  1259.  
  1260.  
  1261. void gl_save_EdgeFlag( GLcontext *ctx, GLboolean flag )
  1262. {
  1263.    Node *n = alloc_instruction( ctx, OPCODE_EDGE_FLAG, 1 );
  1264.    if (n) {
  1265.       n[1].b = flag;
  1266.    }
  1267.    if (ctx->ExecuteFlag) {
  1268.       (*ctx->Exec.EdgeFlag)( ctx, flag );
  1269.    }
  1270. }
  1271.  
  1272.  
  1273. void gl_save_Enable( GLcontext *ctx, GLenum cap )
  1274. {
  1275.    Node *n = alloc_instruction( ctx, OPCODE_ENABLE, 1 );
  1276.    if (n) {
  1277.       n[1].e = cap;
  1278.    }
  1279.    if (ctx->ExecuteFlag) {
  1280.       (*ctx->Exec.Enable)( ctx, cap );
  1281.    }
  1282. }
  1283.  
  1284.  
  1285. void gl_save_End( GLcontext *ctx )
  1286. {
  1287.    (void) alloc_instruction( ctx, OPCODE_END, 0 );
  1288.    if (ctx->ExecuteFlag) {
  1289.       (*ctx->Exec.End)( ctx );
  1290.    }
  1291. }
  1292.  
  1293.  
  1294. void gl_save_EvalCoord1f( GLcontext *ctx, GLfloat u )
  1295. {
  1296.    Node *n = alloc_instruction( ctx, OPCODE_EVALCOORD1, 1 );
  1297.    if (n) {
  1298.       n[1].f = u;
  1299.    }
  1300.    if (ctx->ExecuteFlag) {
  1301.       (*ctx->Exec.EvalCoord1f)( ctx, u );
  1302.    }
  1303. }
  1304.  
  1305.  
  1306. void gl_save_EvalCoord2f( GLcontext *ctx, GLfloat u, GLfloat v )
  1307. {
  1308.    Node *n = alloc_instruction( ctx, OPCODE_EVALCOORD2, 2 );
  1309.    if (n) {
  1310.       n[1].f = u;
  1311.       n[2].f = v;
  1312.    }
  1313.    if (ctx->ExecuteFlag) {
  1314.       (*ctx->Exec.EvalCoord2f)( ctx, u, v );
  1315.    }
  1316. }
  1317.  
  1318.  
  1319. void gl_save_EvalMesh1( GLcontext *ctx,
  1320.             GLenum mode, GLint i1, GLint i2 )
  1321. {
  1322.    Node *n = alloc_instruction( ctx, OPCODE_EVALMESH1, 3 );
  1323.    if (n) {
  1324.       n[1].e = mode;
  1325.       n[2].i = i1;
  1326.       n[3].i = i2;
  1327.    }
  1328.    if (ctx->ExecuteFlag) {
  1329.       (*ctx->Exec.EvalMesh1)( ctx, mode, i1, i2 );
  1330.    }
  1331. }
  1332.  
  1333.  
  1334. void gl_save_EvalMesh2( GLcontext *ctx, 
  1335.             GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2 )
  1336. {
  1337.    Node *n = alloc_instruction( ctx, OPCODE_EVALMESH2, 5 );
  1338.    if (n) {
  1339.       n[1].e = mode;
  1340.       n[2].i = i1;
  1341.       n[3].i = i2;
  1342.       n[4].i = j1;
  1343.       n[5].i = j2;
  1344.    }
  1345.    if (ctx->ExecuteFlag) {
  1346.       (*ctx->Exec.EvalMesh2)( ctx, mode, i1, i2, j1, j2 );
  1347.    }
  1348. }
  1349.  
  1350.  
  1351. void gl_save_EvalPoint1( GLcontext *ctx, GLint i )
  1352. {
  1353.    Node *n = alloc_instruction( ctx, OPCODE_EVALPOINT1, 1 );
  1354.    if (n) {
  1355.       n[1].i = i;
  1356.    }
  1357.    if (ctx->ExecuteFlag) {
  1358.       (*ctx->Exec.EvalPoint1)( ctx, i );
  1359.    }
  1360. }
  1361.  
  1362.  
  1363. void gl_save_EvalPoint2( GLcontext *ctx, GLint i, GLint j )
  1364. {
  1365.    Node *n = alloc_instruction( ctx, OPCODE_EVALPOINT2, 2 );
  1366.    if (n) {
  1367.       n[1].i = i;
  1368.       n[2].i = j;
  1369.    }
  1370.    if (ctx->ExecuteFlag) {
  1371.       (*ctx->Exec.EvalPoint2)( ctx, i, j );
  1372.    }
  1373. }
  1374.  
  1375.  
  1376. void gl_save_Fogfv( GLcontext *ctx, GLenum pname, const GLfloat *params )
  1377. {
  1378.    Node *n = alloc_instruction( ctx, OPCODE_FOG, 5 );
  1379.    if (n) {
  1380.       n[1].e = pname;
  1381.       n[2].f = params[0];
  1382.       n[3].f = params[1];
  1383.       n[4].f = params[2];
  1384.       n[5].f = params[3];
  1385.    }
  1386.    if (ctx->ExecuteFlag) {
  1387.       (*ctx->Exec.Fogfv)( ctx, pname, params );
  1388.    }
  1389. }
  1390.  
  1391.  
  1392. void gl_save_FrontFace( GLcontext *ctx, GLenum mode )
  1393. {
  1394.    Node *n = alloc_instruction( ctx, OPCODE_FRONT_FACE, 1 );
  1395.    if (n) {
  1396.       n[1].e = mode;
  1397.    }
  1398.    if (ctx->ExecuteFlag) {
  1399.       (*ctx->Exec.FrontFace)( ctx, mode );
  1400.    }
  1401. }
  1402.  
  1403.  
  1404. void gl_save_Frustum( GLcontext *ctx, GLdouble left, GLdouble right,
  1405.               GLdouble bottom, GLdouble top,
  1406.               GLdouble nearval, GLdouble farval )
  1407. {
  1408.    Node *n = alloc_instruction( ctx, OPCODE_FRUSTUM, 6 );
  1409.    if (n) {
  1410.       n[1].f = left;
  1411.       n[2].f = right;
  1412.       n[3].f = bottom;
  1413.       n[4].f = top;
  1414.       n[5].f = nearval;
  1415.       n[6].f = farval;
  1416.    }
  1417.    if (ctx->ExecuteFlag) {
  1418.       (*ctx->Exec.Frustum)( ctx, left, right, bottom, top, nearval, farval );
  1419.    }
  1420. }
  1421.  
  1422.  
  1423. void gl_save_Hint( GLcontext *ctx, GLenum target, GLenum mode )
  1424. {
  1425.    Node *n = alloc_instruction( ctx, OPCODE_HINT, 2 );
  1426.    if (n) {
  1427.       n[1].e = target;
  1428.       n[2].e = mode;
  1429.    }
  1430.    if (ctx->ExecuteFlag) {
  1431.       (*ctx->Exec.Hint)( ctx, target, mode );
  1432.    }
  1433. }
  1434.  
  1435.  
  1436. void gl_save_Indexi( GLcontext *ctx, GLint index )
  1437. {
  1438.    Node *n = alloc_instruction( ctx, OPCODE_INDEX, 1 );
  1439.    if (n) {
  1440.       n[1].i = index;
  1441.    }
  1442.    if (ctx->ExecuteFlag) {
  1443.       (*ctx->Exec.Indexi)( ctx, index );
  1444.    }
  1445. }
  1446.  
  1447.  
  1448. void gl_save_Indexf( GLcontext *ctx, GLfloat index )
  1449. {
  1450.    Node *n = alloc_instruction( ctx, OPCODE_INDEX, 1 );
  1451.    if (n) {
  1452.       n[1].i = (GLint) index;
  1453.    }
  1454.    if (ctx->ExecuteFlag) {
  1455.       (*ctx->Exec.Indexf)( ctx,index );
  1456.    }
  1457. }
  1458.  
  1459.  
  1460. void gl_save_IndexMask( GLcontext *ctx, GLuint mask )
  1461. {
  1462.    Node *n = alloc_instruction( ctx, OPCODE_INDEX_MASK, 1 );
  1463.    if (n) {
  1464.       n[1].ui = mask;
  1465.    }
  1466.    if (ctx->ExecuteFlag) {
  1467.       (*ctx->Exec.IndexMask)( ctx, mask );
  1468.    }
  1469. }
  1470.  
  1471.  
  1472. void gl_save_InitNames( GLcontext *ctx )
  1473. {
  1474.    (void) alloc_instruction( ctx, OPCODE_INIT_NAMES, 0 );
  1475.    if (ctx->ExecuteFlag) {
  1476.       (*ctx->Exec.InitNames)( ctx );
  1477.    }
  1478. }
  1479.  
  1480.  
  1481. void gl_save_Lightfv( GLcontext *ctx, GLenum light, GLenum pname,
  1482.               const GLfloat *params, GLint numparams )
  1483. {
  1484.    Node *n = alloc_instruction( ctx, OPCODE_LIGHT, 6 );
  1485.    if (OPCODE_LIGHT) {
  1486.       GLint i;
  1487.       n[1].e = light;
  1488.       n[2].e = pname;
  1489.       for (i=0;i<numparams;i++) {
  1490.      n[3+i].f = params[i];
  1491.       }
  1492.    }
  1493.    if (ctx->ExecuteFlag) {
  1494.       (*ctx->Exec.Lightfv)( ctx, light, pname, params, numparams );
  1495.    }
  1496. }
  1497.  
  1498.  
  1499. void gl_save_LightModelfv( GLcontext *ctx,
  1500.                GLenum pname, const GLfloat *params )
  1501. {
  1502.    Node *n = alloc_instruction( ctx, OPCODE_LIGHT_MODEL, 5 );
  1503.    if (n) {
  1504.       n[1].e = pname;
  1505.       n[2].f = params[0];
  1506.       n[3].f = params[1];
  1507.       n[4].f = params[2];
  1508.       n[5].f = params[3];
  1509.    }
  1510.    if (ctx->ExecuteFlag) {
  1511.       (*ctx->Exec.LightModelfv)( ctx, pname, params );
  1512.    }
  1513. }
  1514.  
  1515.  
  1516. void gl_save_LineStipple( GLcontext *ctx, GLint factor, GLushort pattern )
  1517. {
  1518.    Node *n = alloc_instruction( ctx, OPCODE_LINE_STIPPLE, 2 );
  1519.    if (n) {
  1520.       n[1].i = factor;
  1521.       n[2].us = pattern;
  1522.    }
  1523.    if (ctx->ExecuteFlag) {
  1524.       (*ctx->Exec.LineStipple)( ctx, factor, pattern );
  1525.    }
  1526. }
  1527.  
  1528.  
  1529. void gl_save_LineWidth( GLcontext *ctx, GLfloat width )
  1530. {
  1531.    Node *n = alloc_instruction( ctx, OPCODE_LINE_WIDTH, 1 );
  1532.    if (n) {
  1533.       n[1].f = width;
  1534.    }
  1535.    if (ctx->ExecuteFlag) {
  1536.       (*ctx->Exec.LineWidth)( ctx, width );
  1537.    }
  1538. }
  1539.  
  1540.  
  1541. void gl_save_ListBase( GLcontext *ctx, GLuint base )
  1542. {
  1543.    Node *n = alloc_instruction( ctx, OPCODE_LIST_BASE, 1 );
  1544.    if (n) {
  1545.       n[1].ui = base;
  1546.    }
  1547.    if (ctx->ExecuteFlag) {
  1548.       (*ctx->Exec.ListBase)( ctx, base );
  1549.    }
  1550. }
  1551.  
  1552.  
  1553. void gl_save_LoadIdentity( GLcontext *ctx )
  1554. {
  1555.    (void) alloc_instruction( ctx, OPCODE_LOAD_IDENTITY, 0 );
  1556.    if (ctx->ExecuteFlag) {
  1557.       (*ctx->Exec.LoadIdentity)( ctx );
  1558.    }
  1559. }
  1560.  
  1561.  
  1562. void gl_save_LoadMatrixf( GLcontext *ctx, const GLfloat *m )
  1563. {
  1564.    Node *n = alloc_instruction( ctx, OPCODE_LOAD_MATRIX, 16 );
  1565.    if (n) {
  1566.       GLuint i;
  1567.       for (i=0;i<16;i++) {
  1568.      n[1+i].f = m[i];
  1569.       }
  1570.    }
  1571.    if (ctx->ExecuteFlag) {
  1572.       (*ctx->Exec.LoadMatrixf)( ctx, m );
  1573.    }
  1574. }
  1575.  
  1576.  
  1577. void gl_save_LoadName( GLcontext *ctx, GLuint name )
  1578. {
  1579.    Node *n = alloc_instruction( ctx, OPCODE_LOAD_NAME, 1 );
  1580.    if (n) {
  1581.       n[1].ui = name;
  1582.    }
  1583.    if (ctx->ExecuteFlag) {
  1584.       (*ctx->Exec.LoadName)( ctx, name );
  1585.    }
  1586. }
  1587.  
  1588.  
  1589. void gl_save_LogicOp( GLcontext *ctx, GLenum opcode )
  1590. {
  1591.    Node *n = alloc_instruction( ctx, OPCODE_LOGIC_OP, 1 );
  1592.    if (n) {
  1593.       n[1].e = opcode;
  1594.    }
  1595.    if (ctx->ExecuteFlag) {
  1596.       (*ctx->Exec.LogicOp)( ctx, opcode );
  1597.    }
  1598. }
  1599.  
  1600.  
  1601. void gl_save_Map1f( GLcontext *ctx,
  1602.            GLenum target, GLfloat u1, GLfloat u2, GLint stride,
  1603.            GLint order, const GLfloat *points, GLboolean retain )
  1604. {
  1605.    Node *n = alloc_instruction( ctx, OPCODE_MAP1, 6 );
  1606.    if (n) {
  1607.       n[1].e = target;
  1608.       n[2].f = u1;
  1609.       n[3].f = u2;
  1610.       n[4].i = stride;
  1611.       n[5].i = order;
  1612.       n[6].data = (void *) points;
  1613.    }
  1614.    if (ctx->ExecuteFlag) {
  1615.       (*ctx->Exec.Map1f)( ctx, target, u1, u2, stride, order, points, GL_TRUE );
  1616.    }
  1617.    (void) retain;
  1618. }
  1619.  
  1620.  
  1621. void gl_save_Map2f( GLcontext *ctx, GLenum target,
  1622.             GLfloat u1, GLfloat u2, GLint ustride, GLint uorder,
  1623.             GLfloat v1, GLfloat v2, GLint vstride, GLint vorder,
  1624.             const GLfloat *points, GLboolean retain )
  1625. {
  1626.    Node *n = alloc_instruction( ctx, OPCODE_MAP2, 10 );
  1627.    if (n) {
  1628.       n[1].e = target;
  1629.       n[2].f = u1;
  1630.       n[3].f = u2;
  1631.       n[4].f = v1;
  1632.       n[5].f = v2;
  1633.       n[6].i = ustride;
  1634.       n[7].i = vstride;
  1635.       n[8].i = uorder;
  1636.       n[9].i = vorder;
  1637.       n[10].data = (void *) points;
  1638.    }
  1639.    if (ctx->ExecuteFlag) {
  1640.       (*ctx->Exec.Map2f)( ctx, target,
  1641.             u1, u2, ustride, uorder,
  1642.             v1, v2, vstride, vorder, points, GL_TRUE );
  1643.    }
  1644.    (void) retain;
  1645. }
  1646.  
  1647.  
  1648. void gl_save_MapGrid1f( GLcontext *ctx, GLint un, GLfloat u1, GLfloat u2 )
  1649. {
  1650.    Node *n = alloc_instruction( ctx, OPCODE_MAPGRID1, 3 );
  1651.    if (n) {
  1652.       n[1].i = un;
  1653.       n[2].f = u1;
  1654.       n[3].f = u2;
  1655.    }
  1656.    if (ctx->ExecuteFlag) {
  1657.       (*ctx->Exec.MapGrid1f)( ctx, un, u1, u2 );
  1658.    }
  1659. }
  1660.  
  1661.  
  1662. void gl_save_MapGrid2f( GLcontext *ctx, 
  1663.             GLint un, GLfloat u1, GLfloat u2,
  1664.             GLint vn, GLfloat v1, GLfloat v2 )
  1665. {
  1666.    Node *n = alloc_instruction( ctx, OPCODE_MAPGRID2, 6 );
  1667.    if (n) {
  1668.       n[1].i = un;
  1669.       n[2].f = u1;
  1670.       n[3].f = u2;
  1671.       n[4].i = vn;
  1672.       n[5].f = v1;
  1673.       n[6].f = v2;
  1674.    }
  1675.    if (ctx->ExecuteFlag) {
  1676.       (*ctx->Exec.MapGrid2f)( ctx, un, u1, u2, vn, v1, v2 );
  1677.    }
  1678. }
  1679.  
  1680.  
  1681. void gl_save_Materialfv( GLcontext *ctx,
  1682.              GLenum face, GLenum pname, const GLfloat *params )
  1683. {
  1684.    Node *n = alloc_instruction( ctx, OPCODE_MATERIAL, 6 );
  1685.    if (n) {
  1686.       n[1].e = face;
  1687.       n[2].e = pname;
  1688.       n[3].f = params[0];
  1689.       n[4].f = params[1];
  1690.       n[5].f = params[2];
  1691.       n[6].f = params[3];
  1692.    }
  1693.    if (ctx->ExecuteFlag) {
  1694.       (*ctx->Exec.Materialfv)( ctx, face, pname, params );
  1695.    }
  1696. }
  1697.  
  1698.  
  1699. void gl_save_MatrixMode( GLcontext *ctx, GLenum mode )
  1700. {
  1701.    Node *n = alloc_instruction( ctx, OPCODE_MATRIX_MODE, 1 );
  1702.    if (n) {
  1703.       n[1].e = mode;
  1704.    }
  1705.    if (ctx->ExecuteFlag) {
  1706.       (*ctx->Exec.MatrixMode)( ctx, mode );
  1707.    }
  1708. }
  1709.  
  1710.  
  1711. void gl_save_MultMatrixf( GLcontext *ctx, const GLfloat *m )
  1712. {
  1713.    Node *n = alloc_instruction( ctx, OPCODE_MULT_MATRIX, 16 );
  1714.    if (n) {
  1715.       GLuint i;
  1716.       for (i=0;i<16;i++) {
  1717.      n[1+i].f = m[i];
  1718.       }
  1719.    }
  1720.    if (ctx->ExecuteFlag) {
  1721.       (*ctx->Exec.MultMatrixf)( ctx, m );
  1722.    }
  1723. }
  1724.  
  1725.  
  1726. void gl_save_NewList( GLcontext *ctx, GLuint list, GLenum mode )
  1727. {
  1728.    /* It's an error to call this function while building a display list */
  1729.    gl_error( ctx, GL_INVALID_OPERATION, "glNewList" );
  1730.    (void) list;
  1731.    (void) mode;
  1732. }
  1733.  
  1734.  
  1735. void gl_save_Normal3fv( GLcontext *ctx, const GLfloat norm[3] )
  1736. {
  1737.    Node *n = alloc_instruction( ctx, OPCODE_NORMAL, 3 );
  1738.    if (n) {
  1739.       n[1].f = norm[0];
  1740.       n[2].f = norm[1];
  1741.       n[3].f = norm[2];
  1742.    }
  1743.    if (ctx->ExecuteFlag) {
  1744.       (*ctx->Exec.Normal3fv)( ctx, norm );
  1745.    }
  1746. }
  1747.  
  1748.  
  1749. void gl_save_Normal3f( GLcontext *ctx, GLfloat nx, GLfloat ny, GLfloat nz )
  1750. {
  1751.    Node *n = alloc_instruction( ctx, OPCODE_NORMAL, 3 );
  1752.    if (n) {
  1753.       n[1].f = nx;
  1754.       n[2].f = ny;
  1755.       n[3].f = nz;
  1756.    }
  1757.    if (ctx->ExecuteFlag) {
  1758.       (*ctx->Exec.Normal3f)( ctx, nx, ny, nz );
  1759.    }
  1760. }
  1761.  
  1762.  
  1763. void gl_save_Ortho( GLcontext *ctx, GLdouble left, GLdouble right,
  1764.             GLdouble bottom, GLdouble top,
  1765.             GLdouble nearval, GLdouble farval )
  1766. {
  1767.    Node *n = alloc_instruction( ctx, OPCODE_ORTHO, 6 );
  1768.    if (n) {
  1769.       n[1].f = left;
  1770.       n[2].f = right;
  1771.       n[3].f = bottom;
  1772.       n[4].f = top;
  1773.       n[5].f = nearval;
  1774.       n[6].f = farval;
  1775.    }
  1776.    if (ctx->ExecuteFlag) {
  1777.       (*ctx->Exec.Ortho)( ctx, left, right, bottom, top, nearval, farval );
  1778.    }
  1779. }
  1780.  
  1781.  
  1782. void gl_save_PixelMapfv( GLcontext *ctx,
  1783.              GLenum map, GLint mapsize, const GLfloat *values )
  1784. {
  1785.    Node *n = alloc_instruction( ctx, OPCODE_PIXEL_MAP, 3 );
  1786.    if (n) {
  1787.       n[1].e = map;
  1788.       n[2].i = mapsize;
  1789.       n[3].data  = (void *) malloc( mapsize * sizeof(GLfloat) );
  1790.       MEMCPY( n[3].data, (void *) values, mapsize * sizeof(GLfloat) );
  1791.    }
  1792.    if (ctx->ExecuteFlag) {
  1793.       (*ctx->Exec.PixelMapfv)( ctx, map, mapsize, values );
  1794.    }
  1795. }
  1796.  
  1797.  
  1798. void gl_save_PixelTransferf( GLcontext *ctx, GLenum pname, GLfloat param )
  1799. {
  1800.    Node *n = alloc_instruction( ctx, OPCODE_PIXEL_TRANSFER, 2 );
  1801.    if (n) {
  1802.       n[1].e = pname;
  1803.       n[2].f = param;
  1804.    }
  1805.    if (ctx->ExecuteFlag) {
  1806.       (*ctx->Exec.PixelTransferf)( ctx, pname, param );
  1807.    }
  1808. }
  1809.  
  1810.  
  1811. void gl_save_PixelZoom( GLcontext *ctx, GLfloat xfactor, GLfloat yfactor )
  1812. {
  1813.    Node *n = alloc_instruction( ctx, OPCODE_PIXEL_ZOOM, 2 );
  1814.    if (n) {
  1815.       n[1].f = xfactor;
  1816.       n[2].f = yfactor;
  1817.    }
  1818.    if (ctx->ExecuteFlag) {
  1819.       (*ctx->Exec.PixelZoom)( ctx, xfactor, yfactor );
  1820.    }
  1821. }
  1822.  
  1823.  
  1824. void gl_save_PointParameterfvEXT( GLcontext *ctx, GLenum pname,
  1825.                   const GLfloat *params)
  1826. {
  1827.    Node *n = alloc_instruction( ctx, OPCODE_POINT_PARAMETERS, 4 );
  1828.    if (n) {
  1829.       n[1].e = pname;
  1830.       n[2].f = params[0];
  1831.       n[3].f = params[1];
  1832.       n[4].f = params[2];
  1833.    }
  1834.    if (ctx->ExecuteFlag) {
  1835.       (*ctx->Exec.PointParameterfvEXT)( ctx, pname, params );
  1836.    }
  1837. }
  1838.  
  1839.  
  1840. void gl_save_PointSize( GLcontext *ctx, GLfloat size )
  1841. {
  1842.    Node *n = alloc_instruction( ctx, OPCODE_POINT_SIZE, 1 );
  1843.    if (n) {
  1844.       n[1].f = size;
  1845.    }
  1846.    if (ctx->ExecuteFlag) {
  1847.       (*ctx->Exec.PointSize)( ctx, size );
  1848.    }
  1849. }
  1850.  
  1851.  
  1852. void gl_save_PolygonMode( GLcontext *ctx, GLenum face, GLenum mode )
  1853. {
  1854.    Node *n = alloc_instruction( ctx, OPCODE_POLYGON_MODE, 2 );
  1855.    if (n) {
  1856.       n[1].e = face;
  1857.       n[2].e = mode;
  1858.    }
  1859.    if (ctx->ExecuteFlag) {
  1860.       (*ctx->Exec.PolygonMode)( ctx, face, mode );
  1861.    }
  1862. }
  1863.  
  1864.  
  1865. /*
  1866.  * Polygon stipple must have been upacked already!
  1867.  */
  1868. void gl_save_PolygonStipple( GLcontext *ctx, const GLuint *pattern )
  1869. {
  1870.    Node *n = alloc_instruction( ctx, OPCODE_POLYGON_STIPPLE, 1 );
  1871.    if (n) {
  1872.       void *data;
  1873.       n[1].data = malloc( 32 * 4 );
  1874.       data = n[1].data;   /* This needed for Acorn compiler */
  1875.       MEMCPY( data, pattern, 32 * 4 );
  1876.    }
  1877.    if (ctx->ExecuteFlag) {
  1878.       (*ctx->Exec.PolygonStipple)( ctx, pattern );
  1879.    }
  1880. }
  1881.  
  1882.  
  1883. void gl_save_PolygonOffset( GLcontext *ctx, GLfloat factor, GLfloat units )
  1884. {
  1885.    Node *n = alloc_instruction( ctx, OPCODE_POLYGON_OFFSET, 2 );
  1886.    if (n) {
  1887.       n[1].f = factor;
  1888.       n[2].f = units;
  1889.    }
  1890.    if (ctx->ExecuteFlag) {
  1891.       (*ctx->Exec.PolygonOffset)( ctx, factor, units );
  1892.    }
  1893. }
  1894.  
  1895.  
  1896. void gl_save_PopAttrib( GLcontext *ctx )
  1897. {
  1898.    (void) alloc_instruction( ctx, OPCODE_POP_ATTRIB, 0 );
  1899.    if (ctx->ExecuteFlag) {
  1900.       (*ctx->Exec.PopAttrib)( ctx );
  1901.    }
  1902. }
  1903.  
  1904.  
  1905. void gl_save_PopMatrix( GLcontext *ctx )
  1906. {
  1907.    (void) alloc_instruction( ctx, OPCODE_POP_MATRIX, 0 );
  1908.    if (ctx->ExecuteFlag) {
  1909.       (*ctx->Exec.PopMatrix)( ctx );
  1910.    }
  1911. }
  1912.  
  1913.  
  1914. void gl_save_PopName( GLcontext *ctx )
  1915. {
  1916.    (void) alloc_instruction( ctx, OPCODE_POP_NAME, 0 );
  1917.    if (ctx->ExecuteFlag) {
  1918.       (*ctx->Exec.PopName)( ctx );
  1919.    }
  1920. }
  1921.  
  1922.  
  1923. void gl_save_PrioritizeTextures( GLcontext *ctx,
  1924.                  GLsizei num, const GLuint *textures,
  1925.                  const GLclampf *priorities )
  1926. {
  1927.    GLint i;
  1928.  
  1929.    for (i=0;i<num;i++) {
  1930.       Node *n = alloc_instruction( ctx,  OPCODE_PRIORITIZE_TEXTURE, 2 );
  1931.       if (n) {
  1932.      n[1].ui = textures[i];
  1933.      n[2].f = priorities[i];
  1934.       }
  1935.    }
  1936.    if (ctx->ExecuteFlag) {
  1937.       (*ctx->Exec.PrioritizeTextures)( ctx, num, textures, priorities );
  1938.    }
  1939. }
  1940.  
  1941.  
  1942. void gl_save_PushAttrib( GLcontext *ctx, GLbitfield mask )
  1943. {
  1944.    Node *n = alloc_instruction( ctx, OPCODE_PUSH_ATTRIB, 1 );
  1945.    if (n) {
  1946.       n[1].bf = mask;
  1947.    }
  1948.    if (ctx->ExecuteFlag) {
  1949.       (*ctx->Exec.PushAttrib)( ctx, mask );
  1950.    }
  1951. }
  1952.  
  1953.  
  1954. void gl_save_PushMatrix( GLcontext *ctx )
  1955. {
  1956.    (void) alloc_instruction( ctx, OPCODE_PUSH_MATRIX, 0 );
  1957.    if (ctx->ExecuteFlag) {
  1958.       (*ctx->Exec.PushMatrix)( ctx );
  1959.    }
  1960. }
  1961.  
  1962.  
  1963. void gl_save_PushName( GLcontext *ctx, GLuint name )
  1964. {
  1965.    Node *n = alloc_instruction( ctx, OPCODE_PUSH_NAME, 1 );
  1966.    if (n) {
  1967.       n[1].ui = name;
  1968.    }
  1969.    if (ctx->ExecuteFlag) {
  1970.       (*ctx->Exec.PushName)( ctx, name );
  1971.    }
  1972. }
  1973.  
  1974.  
  1975. void gl_save_RasterPos4f( GLcontext *ctx,
  1976.               GLfloat x, GLfloat y, GLfloat z, GLfloat w )
  1977. {
  1978.    Node *n = alloc_instruction( ctx, OPCODE_RASTER_POS, 4 );
  1979.    if (n) {
  1980.       n[1].f = x;
  1981.       n[2].f = y;
  1982.       n[3].f = z;
  1983.       n[4].f = w;
  1984.    }
  1985.    if (ctx->ExecuteFlag) {
  1986.       (*ctx->Exec.RasterPos4f)( ctx, x, y, z, w );
  1987.    }
  1988. }
  1989.  
  1990.  
  1991. void gl_save_PassThrough( GLcontext *ctx, GLfloat token )
  1992. {
  1993.    Node *n = alloc_instruction( ctx, OPCODE_PASSTHROUGH, 1 );
  1994.    if (n) {
  1995.       n[1].f = token;
  1996.    }
  1997.    if (ctx->ExecuteFlag) {
  1998.       (*ctx->Exec.PassThrough)( ctx, token );
  1999.    }
  2000. }
  2001.  
  2002.  
  2003. void gl_save_ReadBuffer( GLcontext *ctx, GLenum mode )
  2004. {
  2005.    Node *n = alloc_instruction( ctx, OPCODE_READ_BUFFER, 1 );
  2006.    if (n) {
  2007.       n[1].e = mode;
  2008.    }
  2009.    if (ctx->ExecuteFlag) {
  2010.       (*ctx->Exec.ReadBuffer)( ctx, mode );
  2011.    }
  2012. }
  2013.  
  2014.  
  2015. void gl_save_Rectf( GLcontext *ctx,
  2016.             GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2 )
  2017. {
  2018.    Node *n = alloc_instruction( ctx, OPCODE_RECTF, 4 );
  2019.    if (n) {
  2020.       n[1].f = x1;
  2021.       n[2].f = y1;
  2022.       n[3].f = x2;
  2023.       n[4].f = y2;
  2024.    }
  2025.    if (ctx->ExecuteFlag) {
  2026.       (*ctx->Exec.Rectf)( ctx, x1, y1, x2, y2 );
  2027.    }
  2028. }
  2029.  
  2030.  
  2031. void gl_save_Rotatef( GLcontext *ctx, GLfloat angle,
  2032.               GLfloat x, GLfloat y, GLfloat z )
  2033. {
  2034.    GLfloat m[16];
  2035.    gl_rotation_matrix( angle, x, y, z, m );
  2036.    gl_save_MultMatrixf( ctx, m );  /* save and maybe execute */
  2037. }
  2038.  
  2039.  
  2040. void gl_save_Scalef( GLcontext *ctx, GLfloat x, GLfloat y, GLfloat z )
  2041. {
  2042.    Node *n = alloc_instruction( ctx, OPCODE_SCALE, 3 );
  2043.    if (n) {
  2044.       n[1].f = x;
  2045.       n[2].f = y;
  2046.       n[3].f = z;
  2047.    }
  2048.    if (ctx->ExecuteFlag) {
  2049.       (*ctx->Exec.Scalef)( ctx, x, y, z );
  2050.    }
  2051. }
  2052.  
  2053.  
  2054. void gl_save_Scissor( GLcontext *ctx,
  2055.               GLint x, GLint y, GLsizei width, GLsizei height )
  2056. {
  2057.    Node *n = alloc_instruction( ctx, OPCODE_SCISSOR, 4 );
  2058.    if (n) {
  2059.       n[1].i = x;
  2060.       n[2].i = y;
  2061.       n[3].i = width;
  2062.       n[4].i = height;
  2063.    }
  2064.    if (ctx->ExecuteFlag) {
  2065.       (*ctx->Exec.Scissor)( ctx, x, y, width, height );
  2066.    }
  2067. }
  2068.  
  2069.  
  2070. void gl_save_ShadeModel( GLcontext *ctx, GLenum mode )
  2071. {
  2072.    Node *n = alloc_instruction( ctx, OPCODE_SHADE_MODEL, 1 );
  2073.    if (n) {
  2074.       n[1].e = mode;
  2075.    }
  2076.    if (ctx->ExecuteFlag) {
  2077.       (*ctx->Exec.ShadeModel)( ctx, mode );
  2078.    }
  2079. }
  2080.  
  2081.  
  2082. void gl_save_StencilFunc( GLcontext *ctx, GLenum func, GLint ref, GLuint mask )
  2083. {
  2084.    Node *n = alloc_instruction( ctx, OPCODE_STENCIL_FUNC, 3 );
  2085.    if (n) {
  2086.       n[1].e = func;
  2087.       n[2].i = ref;
  2088.       n[3].ui = mask;
  2089.    }
  2090.    if (ctx->ExecuteFlag) {
  2091.       (*ctx->Exec.StencilFunc)( ctx, func, ref, mask );
  2092.    }
  2093. }
  2094.  
  2095.  
  2096. void gl_save_StencilMask( GLcontext *ctx, GLuint mask )
  2097. {
  2098.    Node *n = alloc_instruction( ctx, OPCODE_STENCIL_MASK, 1 );
  2099.    if (n) {
  2100.       n[1].ui = mask;
  2101.    }
  2102.    if (ctx->ExecuteFlag) {
  2103.       (*ctx->Exec.StencilMask)( ctx, mask );
  2104.    }
  2105. }
  2106.  
  2107.  
  2108. void gl_save_StencilOp( GLcontext *ctx,
  2109.             GLenum fail, GLenum zfail, GLenum zpass )
  2110. {
  2111.    Node *n = alloc_instruction( ctx, OPCODE_STENCIL_OP, 3 );
  2112.    if (n) {
  2113.       n[1].e = fail;
  2114.       n[2].e = zfail;
  2115.       n[3].e = zpass;
  2116.    }
  2117.    if (ctx->ExecuteFlag) {
  2118.       (*ctx->Exec.StencilOp)( ctx, fail, zfail, zpass );
  2119.    }
  2120. }
  2121.  
  2122.  
  2123. void gl_save_TexCoord2f( GLcontext *ctx, GLfloat s, GLfloat t )
  2124. {
  2125.    Node *n = alloc_instruction( ctx, OPCODE_TEXCOORD2, 2 );
  2126.    if (n) {
  2127.       n[1].f = s;
  2128.       n[2].f = t;
  2129.    }
  2130.    if (ctx->ExecuteFlag) {
  2131.       (*ctx->Exec.TexCoord2f)( ctx, s, t );
  2132.    }
  2133. }
  2134.  
  2135.  
  2136. void gl_save_TexCoord4f( GLcontext *ctx, GLfloat s, GLfloat t,
  2137.                      GLfloat r, GLfloat q )
  2138. {
  2139.    Node *n = alloc_instruction( ctx, OPCODE_TEXCOORD4, 4 );
  2140.    if (n) {
  2141.       n[1].f = s;
  2142.       n[2].f = t;
  2143.       n[3].f = r;
  2144.       n[4].f = q;
  2145.    }
  2146.    if (ctx->ExecuteFlag) {
  2147.       (*ctx->Exec.TexCoord4f)( ctx, s, t, r, q );
  2148.    }
  2149. }
  2150.  
  2151.  
  2152. void gl_save_TexEnvfv( GLcontext *ctx,
  2153.                GLenum target, GLenum pname, const GLfloat *params )
  2154. {
  2155.    Node *n = alloc_instruction( ctx, OPCODE_TEXENV, 6 );
  2156.    if (n) {
  2157.       n[1].e = target;
  2158.       n[2].e = pname;
  2159.       n[3].f = params[0];
  2160.       n[4].f = params[1];
  2161.       n[5].f = params[2];
  2162.       n[6].f = params[3];
  2163.    }
  2164.    if (ctx->ExecuteFlag) {
  2165.       (*ctx->Exec.TexEnvfv)( ctx, target, pname, params );
  2166.    }
  2167. }
  2168.  
  2169.  
  2170. void gl_save_TexGenfv( GLcontext *ctx,
  2171.                GLenum coord, GLenum pname, const GLfloat *params )
  2172. {
  2173.    Node *n = alloc_instruction( ctx, OPCODE_TEXGEN, 6 );
  2174.    if (n) {
  2175.       n[1].e = coord;
  2176.       n[2].e = pname;
  2177.       n[3].f = params[0];
  2178.       n[4].f = params[1];
  2179.       n[5].f = params[2];
  2180.       n[6].f = params[3];
  2181.    }
  2182.    if (ctx->ExecuteFlag) {
  2183.       (*ctx->Exec.TexGenfv)( ctx, coord, pname, params );
  2184.    }
  2185. }
  2186.  
  2187.  
  2188. void gl_save_TexParameterfv( GLcontext *ctx, GLenum target,
  2189.                  GLenum pname, const GLfloat *params )
  2190. {
  2191.    Node *n = alloc_instruction( ctx, OPCODE_TEXPARAMETER, 6 );
  2192.    if (n) {
  2193.       n[1].e = target;
  2194.       n[2].e = pname;
  2195.       n[3].f = params[0];
  2196.       n[4].f = params[1];
  2197.       n[5].f = params[2];
  2198.       n[6].f = params[3];
  2199.    }
  2200.    if (ctx->ExecuteFlag) {
  2201.       (*ctx->Exec.TexParameterfv)( ctx, target, pname, params );
  2202.    }
  2203. }
  2204.  
  2205.  
  2206. void gl_save_TexImage1D( GLcontext *ctx, GLenum target,
  2207.              GLint level, GLint components,
  2208.              GLsizei width, GLint border,
  2209.              GLenum format, GLenum type,
  2210.              struct gl_image *teximage )
  2211. {
  2212.    Node *n = alloc_instruction( ctx, OPCODE_TEX_IMAGE1D, 8 );
  2213.    if (n) {
  2214.       n[1].e = target;
  2215.       n[2].i = level;
  2216.       n[3].i = components;
  2217.       n[4].i = (GLint) width;
  2218.       n[5].i = border;
  2219.       n[6].e = format;
  2220.       n[7].e = type;
  2221.       n[8].data = teximage;
  2222.       if (teximage) {
  2223.      /* this prevents gl_TexImage2D() from freeing the image */
  2224.      teximage->RefCount = 1;
  2225.       }
  2226.    }
  2227.    if (ctx->ExecuteFlag) {
  2228.       (*ctx->Exec.TexImage1D)( ctx, target, level, components, width,
  2229.             border, format, type, teximage );
  2230.    }
  2231. }
  2232.  
  2233.  
  2234. void gl_save_TexImage2D( GLcontext *ctx, GLenum target,
  2235.              GLint level, GLint components,
  2236.              GLsizei width, GLsizei height, GLint border,
  2237.              GLenum format, GLenum type,
  2238.              struct gl_image *teximage )
  2239. {
  2240.    Node *n = alloc_instruction( ctx, OPCODE_TEX_IMAGE2D, 9 );
  2241.    if (n) {
  2242.       n[1].e = target;
  2243.       n[2].i = level;
  2244.       n[3].i = components;
  2245.       n[4].i = (GLint) width;
  2246.       n[5].i = (GLint) height;
  2247.       n[6].i = border;
  2248.       n[7].e = format;
  2249.       n[8].e = type;
  2250.       n[9].data = teximage;
  2251.       if (teximage) {
  2252.      /* this prevents gl_TexImage2D() from freeing the image */
  2253.      teximage->RefCount = 1;
  2254.       }
  2255.    }
  2256.    if (ctx->ExecuteFlag) {
  2257.       (*ctx->Exec.TexImage2D)( ctx, target, level, components, width,
  2258.             height, border, format, type, teximage );
  2259.    }
  2260. }
  2261.  
  2262.  
  2263. void gl_save_TexImage3DEXT( GLcontext *ctx, GLenum target,
  2264.                 GLint level, GLint components,
  2265.                 GLsizei width, GLsizei height, GLsizei depth,
  2266.                 GLint border,
  2267.                 GLenum format, GLenum type,
  2268.                 struct gl_image *teximage )
  2269. {
  2270.    Node *n = alloc_instruction( ctx, OPCODE_TEX_IMAGE3D, 10 );
  2271.    if (n) {
  2272.       n[1].e = target;
  2273.       n[2].i = level;
  2274.       n[3].i = components;
  2275.       n[4].i = (GLint) width;
  2276.       n[5].i = (GLint) height;
  2277.       n[6].i = (GLint) depth; 
  2278.       n[7].i = border;
  2279.       n[8].e = format;
  2280.       n[9].e = type;
  2281.       n[10].data = teximage;
  2282.    }
  2283.    if (ctx->ExecuteFlag) {
  2284.       (*ctx->Exec.TexImage3DEXT)( ctx, target, level, components, width,
  2285.                height, depth, border, format, type, teximage );
  2286.    }
  2287. }
  2288.  
  2289.  
  2290. void gl_save_TexSubImage1D( GLcontext *ctx,
  2291.                 GLenum target, GLint level, GLint xoffset,
  2292.                 GLsizei width, GLenum format, GLenum type,
  2293.                 struct gl_image *image )
  2294. {
  2295.    Node *n = alloc_instruction( ctx, OPCODE_TEX_SUB_IMAGE1D, 7 );
  2296.    if (n) {
  2297.       n[1].e = target;
  2298.       n[2].i = level;
  2299.       n[3].i = xoffset;
  2300.       n[4].i = (GLint) width;
  2301.       n[5].e = format;
  2302.       n[6].e = type;
  2303.       n[7].data = image;
  2304.       if (image)
  2305.      image->RefCount = 1;
  2306.    }
  2307.    if (ctx->ExecuteFlag) {
  2308.       (*ctx->Exec.TexSubImage1D)( ctx, target, level, xoffset, width,
  2309.                format, type, image );
  2310.    }
  2311. }
  2312.  
  2313.  
  2314. void gl_save_TexSubImage2D( GLcontext *ctx,
  2315.                 GLenum target, GLint level,
  2316.                 GLint xoffset, GLint yoffset,
  2317.                 GLsizei width, GLsizei height,
  2318.                 GLenum format, GLenum type,
  2319.                 struct gl_image *image )
  2320. {
  2321.    Node *n = alloc_instruction( ctx, OPCODE_TEX_SUB_IMAGE2D, 9 );
  2322.    if (n) {
  2323.       n[1].e = target;
  2324.       n[2].i = level;
  2325.       n[3].i = xoffset;
  2326.       n[4].i = yoffset;
  2327.       n[5].i = (GLint) width;
  2328.       n[6].i = (GLint) height;
  2329.       n[7].e = format;
  2330.       n[8].e = type;
  2331.       n[9].data = image;
  2332.       if (image)
  2333.      image->RefCount = 1;
  2334.    }
  2335.    if (ctx->ExecuteFlag) {
  2336.       (*ctx->Exec.TexSubImage2D)( ctx, target, level, xoffset, yoffset,
  2337.                width, height, format, type, image );
  2338.    }
  2339. }
  2340.  
  2341.  
  2342. void gl_save_TexSubImage3DEXT( GLcontext *ctx,
  2343.                    GLenum target, GLint level,
  2344.                    GLint xoffset, GLint yoffset,GLint zoffset,
  2345.                    GLsizei width, GLsizei height, GLsizei depth,
  2346.                    GLenum format, GLenum type,
  2347.                    struct gl_image *image )
  2348. {
  2349.    Node *n = alloc_instruction( ctx, OPCODE_TEX_SUB_IMAGE3D, 11 );
  2350.    if (n) {
  2351.       n[1].e = target;
  2352.       n[2].i = level;
  2353.       n[3].i = xoffset;
  2354.       n[4].i = yoffset;
  2355.       n[5].i = zoffset;
  2356.       n[6].i = (GLint) width;
  2357.       n[7].i = (GLint) height;
  2358.       n[8].i = (GLint) depth;
  2359.       n[9].e = format;
  2360.       n[10].e = type;
  2361.       n[11].data = image;
  2362.       if (image)
  2363.      image->RefCount = 1;
  2364.    }
  2365.    if (ctx->ExecuteFlag) {
  2366.       (*ctx->Exec.TexSubImage3DEXT)( ctx, target, level, xoffset, yoffset, zoffset,
  2367.                   width, height, depth, format, type, image );
  2368.    }
  2369. }
  2370.  
  2371.  
  2372. void gl_save_Translatef( GLcontext *ctx, GLfloat x, GLfloat y, GLfloat z )
  2373. {
  2374.    Node *n = alloc_instruction( ctx,  OPCODE_TRANSLATE, 3 );
  2375.    if (n) {
  2376.       n[1].f = x;
  2377.       n[2].f = y;
  2378.       n[3].f = z;
  2379.    }
  2380.    if (ctx->ExecuteFlag) {
  2381.       (*ctx->Exec.Translatef)( ctx, x, y, z );
  2382.    }
  2383. }
  2384.  
  2385.  
  2386. void gl_save_Vertex2f( GLcontext *ctx, GLfloat x, GLfloat y )
  2387. {
  2388.    Node *n = alloc_instruction( ctx,  OPCODE_VERTEX2, 2 );
  2389.    if (n) {
  2390.       n[1].f = x;
  2391.       n[2].f = y;
  2392.    }
  2393.    if (ctx->ExecuteFlag) {
  2394.       (*ctx->Exec.Vertex2f)( ctx, x, y );
  2395.    }
  2396. }
  2397.  
  2398.  
  2399. void gl_save_Vertex3f( GLcontext *ctx, GLfloat x, GLfloat y, GLfloat z )
  2400. {
  2401.    Node *n = alloc_instruction( ctx,  OPCODE_VERTEX3, 3 );
  2402.    if (n) {
  2403.       n[1].f = x;
  2404.       n[2].f = y;
  2405.       n[3].f = z;
  2406.    }
  2407.    if (ctx->ExecuteFlag) {
  2408.       (*ctx->Exec.Vertex3f)( ctx, x, y, z );
  2409.    }
  2410. }
  2411.  
  2412.  
  2413. void gl_save_Vertex4f( GLcontext *ctx,
  2414.                GLfloat x, GLfloat y, GLfloat z, GLfloat w )
  2415. {
  2416.    Node *n = alloc_instruction( ctx,  OPCODE_VERTEX4, 4 );
  2417.    if (n) {
  2418.       n[1].f = x;
  2419.       n[2].f = y;
  2420.       n[3].f = z;
  2421.       n[4].f = w;
  2422.    }
  2423.    if (ctx->ExecuteFlag) {
  2424.       (*ctx->Exec.Vertex4f)( ctx, x, y, z, w );
  2425.    }
  2426. }
  2427.  
  2428.  
  2429. void gl_save_Vertex3fv( GLcontext *ctx, const GLfloat v[3] )
  2430. {
  2431.    Node *n = alloc_instruction( ctx,  OPCODE_VERTEX3, 3 );
  2432.    if (n) {
  2433.       n[1].f = v[0];
  2434.       n[2].f = v[1];
  2435.       n[3].f = v[2];
  2436.    }
  2437.    if (ctx->ExecuteFlag) {
  2438.       (*ctx->Exec.Vertex3fv)( ctx, v );
  2439.    }
  2440. }
  2441.  
  2442.  
  2443. void gl_save_Viewport( GLcontext *ctx,
  2444.                GLint x, GLint y, GLsizei width, GLsizei height )
  2445. {
  2446.    Node *n = alloc_instruction( ctx,  OPCODE_VIEWPORT, 4 );
  2447.    if (n) {
  2448.       n[1].i = x;
  2449.       n[2].i = y;
  2450.       n[3].i = (GLint) width;
  2451.       n[4].i = (GLint) height;
  2452.    }
  2453.    if (ctx->ExecuteFlag) {
  2454.       (*ctx->Exec.Viewport)( ctx, x, y, width, height );
  2455.    }
  2456. }
  2457.  
  2458.  
  2459. void gl_save_WindowPos4fMESA( GLcontext *ctx,
  2460.                   GLfloat x, GLfloat y, GLfloat z, GLfloat w )
  2461. {
  2462.    Node *n = alloc_instruction( ctx,  OPCODE_WINDOW_POS, 4 );
  2463.    if (n) {
  2464.       n[1].f = x;
  2465.       n[2].f = y;
  2466.       n[3].f = z;
  2467.       n[4].f = w;
  2468.    }
  2469.    if (ctx->ExecuteFlag) {
  2470.       (*ctx->Exec.WindowPos4fMESA)( ctx, x, y, z, w );
  2471.    }
  2472. }
  2473.  
  2474.  
  2475. /* GL_SGIS_multitexture */
  2476. void gl_save_MultiTexCoord4f( GLcontext *ctx, GLenum target,
  2477.                   GLfloat s, GLfloat t, GLfloat r, GLfloat q )
  2478. {
  2479.    Node *n = alloc_instruction( ctx, OPCODE_MULTI_TEXCOORD4, 5);
  2480.    if (n) {
  2481.       n[1].e = target;
  2482.       n[2].f = s;
  2483.       n[3].f = t;
  2484.       n[4].f = r;
  2485.       n[5].f = q;
  2486.    }
  2487.    if (ctx->ExecuteFlag) {
  2488.       (*ctx->Exec.MultiTexCoord4f)( ctx, target, s, t, r, q );
  2489.    }
  2490. }
  2491.  
  2492.  
  2493. /* GL_SGIS_multitexture */
  2494. void gl_save_SelectTextureSGIS( GLcontext *ctx, GLenum target )
  2495. {
  2496.    Node *n = alloc_instruction( ctx, OPCODE_SELECT_TEXTURE_SGIS, 1 );
  2497.    if (n) {
  2498.       n[1].e = target;
  2499.    }
  2500.    if (ctx->ExecuteFlag) {
  2501.       (*ctx->Exec.SelectTextureSGIS)( ctx, target );
  2502.    }
  2503. }
  2504.  
  2505.  
  2506. /* GL_EXT_multitexture */
  2507. void gl_save_SelectTexture( GLcontext *ctx, GLenum target )
  2508. {
  2509.    Node *n = alloc_instruction( ctx, OPCODE_SELECT_TEXTURE, 1 );
  2510.    if (n) {
  2511.       n[1].e = target;
  2512.    }
  2513.    if (ctx->ExecuteFlag) {
  2514.       (*ctx->Exec.SelectTexture)( ctx, target );
  2515.    }
  2516. }
  2517.  
  2518.  
  2519. /* GL_SGIS_multitexture */
  2520. void gl_save_SelectTextureCoordSet( GLcontext *ctx, GLenum target )
  2521. {
  2522.    Node *n = alloc_instruction( ctx, OPCODE_SELECT_TEXTURE_COORD_SET, 1 );
  2523.    if (n) {
  2524.       n[1].e = target;
  2525.    }
  2526.    if (ctx->ExecuteFlag) {
  2527.       (*ctx->Exec.SelectTextureCoordSet)( ctx, target );
  2528.    }
  2529. }
  2530.  
  2531.  
  2532. /* GL_EXT_multitexture */
  2533. void gl_save_SelectTextureTransform( GLcontext *ctx, GLenum target )
  2534. {
  2535.    Node *n = alloc_instruction( ctx, OPCODE_SELECT_TEXTURE_TRANSFORM, 1 );
  2536.    if (n) {
  2537.       n[1].e = target;
  2538.    }
  2539.    if (ctx->ExecuteFlag) {
  2540.       (*ctx->Exec.SelectTextureTransform)( ctx, target );
  2541.    }
  2542. }
  2543.  
  2544.  
  2545.  
  2546.  
  2547.  
  2548.  
  2549. /**********************************************************************/
  2550. /*                     Display list execution                         */
  2551. /**********************************************************************/
  2552.  
  2553. /* computer bug workaround */
  2554. #if (defined(__STORM__) && defined(__PPC__))
  2555. GLfloat g_params[16];
  2556. #endif
  2557.  
  2558. /*
  2559.  * Execute a display list.  Note that the ListBase offset must have already
  2560.  * been added before calling this function.  I.e. the list argument is
  2561.  * the absolute list number, not relative to ListBase.
  2562.  * Input:  list - display list number
  2563.  */
  2564. static void execute_list( GLcontext *ctx, GLuint list )
  2565. {
  2566.    Node *n;
  2567.    GLboolean done;
  2568.    OpCode opcode;
  2569.  
  2570.    if (!gl_IsList(ctx,list))
  2571.       return;
  2572.  
  2573.    ctx->CallDepth++;
  2574.  
  2575.    n = (Node *) HashLookup(ctx->Shared->DisplayList, list);
  2576.  
  2577.    done = GL_FALSE;
  2578.    while (!done) {
  2579.       opcode = n[0].opcode;
  2580. #ifdef AMIGA
  2581.       switch (opcode) {
  2582.      case OPCODE_VERTEX3:
  2583.         (*ctx->Exec.Vertex3f)( ctx, n[1].f, n[2].f, n[3].f );
  2584.         break;
  2585.      case OPCODE_NORMAL:
  2586.         ctx->Current.Normal[0] = n[1].f;
  2587.         ctx->Current.Normal[1] = n[2].f;
  2588.         ctx->Current.Normal[2] = n[3].f;
  2589.         ctx->VB->MonoNormal = GL_FALSE;
  2590.         break;
  2591.      case OPCODE_COLOR_3F:
  2592.         (*ctx->Exec.Color3f)( ctx, n[1].f, n[2].f, n[3].f );
  2593.         break;
  2594.      case OPCODE_TEXCOORD2:
  2595.         ctx->Current.TexCoord[0] = n[1].f;
  2596.         ctx->Current.TexCoord[1] = n[2].f;
  2597.         if (ctx->VB->TexCoordSize==4) {
  2598.            ctx->Current.TexCoord[2] = 0.0F;
  2599.            ctx->Current.TexCoord[3] = 1.0F;
  2600.         }
  2601.         break;
  2602.      default:
  2603. #endif
  2604.       switch (opcode) {
  2605.      /* Frequently called functions: */
  2606.      case OPCODE_VERTEX2:
  2607.         (*ctx->Exec.Vertex2f)( ctx, n[1].f, n[2].f );
  2608.         break;
  2609. #ifndef AMIGA
  2610.      case OPCODE_VERTEX3:
  2611.         (*ctx->Exec.Vertex3f)( ctx, n[1].f, n[2].f, n[3].f );
  2612.         break;
  2613. #endif
  2614.      case OPCODE_VERTEX4:
  2615.         (*ctx->Exec.Vertex4f)( ctx, n[1].f, n[2].f, n[3].f, n[4].f );
  2616.         break;
  2617. #ifndef AMIGA
  2618.      case OPCODE_NORMAL:
  2619.         ctx->Current.Normal[0] = n[1].f;
  2620.         ctx->Current.Normal[1] = n[2].f;
  2621.         ctx->Current.Normal[2] = n[3].f;
  2622.         ctx->VB->MonoNormal = GL_FALSE;
  2623.         break;
  2624. #endif
  2625.      case OPCODE_COLOR_4UB:
  2626.         (*ctx->Exec.Color4ub)( ctx, n[1].ub, n[2].ub, n[3].ub, n[4].ub );
  2627.         break;
  2628. #ifndef AMIGA
  2629.      case OPCODE_COLOR_3F:
  2630.         (*ctx->Exec.Color3f)( ctx, n[1].f, n[2].f, n[3].f );
  2631.         break;
  2632. #endif
  2633.      case OPCODE_COLOR_4F:
  2634.         (*ctx->Exec.Color4f)( ctx, n[1].f, n[2].f, n[3].f, n[4].f );
  2635.         break;
  2636.      case OPCODE_INDEX:
  2637.         ctx->Current.Index = n[1].ui;
  2638.         ctx->VB->MonoColor = GL_FALSE;
  2639.         break;
  2640.      case OPCODE_BEGIN:
  2641.         gl_Begin( ctx, n[1].e );
  2642.         break;
  2643.      case OPCODE_END:
  2644.         gl_End( ctx );
  2645.         break;
  2646. #ifndef AMIGA
  2647.      case OPCODE_TEXCOORD2:
  2648.         ctx->Current.TexCoord[0] = n[1].f;
  2649.         ctx->Current.TexCoord[1] = n[2].f;
  2650.         if (ctx->VB->TexCoordSize==4) {
  2651.            ctx->Current.TexCoord[2] = 0.0F;
  2652.            ctx->Current.TexCoord[3] = 1.0F;
  2653.         }
  2654.         break;
  2655. #endif
  2656.      case OPCODE_TEXCOORD4:
  2657.         ctx->Current.TexCoord[0] = n[1].f;
  2658.         ctx->Current.TexCoord[1] = n[2].f;
  2659.         ctx->Current.TexCoord[2] = n[3].f;
  2660.         ctx->Current.TexCoord[3] = n[4].f;
  2661.         if (ctx->VB->TexCoordSize==2) {
  2662.            /* Switch to 4-component texcoords */
  2663.            ctx->VB->TexCoordSize = 4;
  2664.            gl_set_vertex_function(ctx);
  2665.         }
  2666.         break;
  2667.  
  2668.      /* Everything Else: */
  2669.      case OPCODE_ACCUM:
  2670.         gl_Accum( ctx, n[1].e, n[2].f );
  2671.         break;
  2672.      case OPCODE_ALPHA_FUNC:
  2673.         gl_AlphaFunc( ctx, n[1].e, n[2].f );
  2674.         break;
  2675.      case OPCODE_BIND_TEXTURE:
  2676.         gl_BindTexture( ctx, n[1].e, n[2].ui );
  2677.         break;
  2678.      case OPCODE_BITMAP:
  2679.         gl_Bitmap( ctx, (GLsizei) n[1].i, (GLsizei) n[2].i,
  2680.                n[3].f, n[4].f,
  2681.                n[5].f, n[6].f,
  2682.                (struct gl_image *) n[7].data );
  2683.         break;
  2684.      case OPCODE_BLEND_COLOR:
  2685.         gl_BlendColor( ctx, n[1].f, n[2].f, n[3].f, n[4].f );
  2686.         break;
  2687.      case OPCODE_BLEND_EQUATION:
  2688.         gl_BlendEquation( ctx, n[1].e );
  2689.         break;
  2690.      case OPCODE_BLEND_FUNC:
  2691.         gl_BlendFunc( ctx, n[1].e, n[2].e );
  2692.         break;
  2693.      case OPCODE_CALL_LIST:
  2694.         /* Generated by glCallList(), don't add ListBase */
  2695.         if (ctx->CallDepth<MAX_LIST_NESTING) {
  2696.            execute_list( ctx, n[1].ui );
  2697.         }
  2698.         break;
  2699.      case OPCODE_CALL_LIST_OFFSET:
  2700.         /* Generated by glCallLists() so we must add ListBase */
  2701.         if (ctx->CallDepth<MAX_LIST_NESTING) {
  2702.            execute_list( ctx, ctx->List.ListBase + n[1].ui );
  2703.         }
  2704.         break;
  2705.      case OPCODE_CLEAR:
  2706.         gl_Clear( ctx, n[1].bf );
  2707.         break;
  2708.      case OPCODE_CLEAR_COLOR:
  2709.         gl_ClearColor( ctx, n[1].f, n[2].f, n[3].f, n[4].f );
  2710.         break;
  2711.      case OPCODE_CLEAR_ACCUM:
  2712.         gl_ClearAccum( ctx, n[1].f, n[2].f, n[3].f, n[4].f );
  2713.         break;
  2714.      case OPCODE_CLEAR_DEPTH:
  2715.         gl_ClearDepth( ctx, (GLclampd) n[1].f );
  2716.         break;
  2717.      case OPCODE_CLEAR_INDEX:
  2718.         gl_ClearIndex( ctx, n[1].ui );
  2719.         break;
  2720.      case OPCODE_CLEAR_STENCIL:
  2721.         gl_ClearStencil( ctx, n[1].i );
  2722.         break;
  2723.      case OPCODE_CLIP_PLANE:
  2724.         {
  2725. #if (defined(__STORM__) && defined(__PPC__))
  2726.            g_params[0] = n[2].f;
  2727.            g_params[1] = n[3].f;
  2728.            g_params[2] = n[4].f;
  2729.            g_params[3] = n[5].f;
  2730.            gl_ClipPlane( ctx, n[1].e, g_params );
  2731. #else
  2732.            GLfloat equ[4];
  2733.            equ[0] = n[2].f;
  2734.            equ[1] = n[3].f;
  2735.            equ[2] = n[4].f;
  2736.            equ[3] = n[5].f;
  2737.            gl_ClipPlane( ctx, n[1].e, equ );
  2738. #endif
  2739.         }
  2740.         break;
  2741.      case OPCODE_COLOR_MASK:
  2742.         gl_ColorMask( ctx, n[1].b, n[2].b, n[3].b, n[4].b );
  2743.         break;
  2744.      case OPCODE_COLOR_MATERIAL:
  2745.         gl_ColorMaterial( ctx, n[1].e, n[2].e );
  2746.         break;
  2747.      case OPCODE_COLOR_TABLE:
  2748.         gl_ColorTable( ctx, n[1].e, n[2].e, (struct gl_image *) n[3].data);
  2749.         break;
  2750.      case OPCODE_COLOR_SUB_TABLE:
  2751.         gl_ColorSubTable( ctx, n[1].e, n[2].i,
  2752.                   (struct gl_image *) n[3].data);
  2753.         break;
  2754.      case OPCODE_COPY_PIXELS:
  2755.         gl_CopyPixels( ctx, n[1].i, n[2].i,
  2756.                (GLsizei) n[3].i, (GLsizei) n[4].i, n[5].e );
  2757.         break;
  2758.      case OPCODE_COPY_TEX_IMAGE1D:
  2759.         gl_CopyTexImage1D( ctx, n[1].e, n[2].i, n[3].e, n[4].i,
  2760.                    n[5].i, n[6].i, n[7].i );
  2761.         break;
  2762.      case OPCODE_COPY_TEX_IMAGE2D:
  2763.         gl_CopyTexImage2D( ctx, n[1].e, n[2].i, n[3].e, n[4].i,
  2764.                    n[5].i, n[6].i, n[7].i, n[8].i );
  2765.         break;
  2766.      case OPCODE_COPY_TEX_SUB_IMAGE1D:
  2767.         gl_CopyTexSubImage1D( ctx, n[1].e, n[2].i, n[3].i, n[4].i,
  2768.                   n[5].i, n[6].i );
  2769.         break;
  2770.      case OPCODE_COPY_TEX_SUB_IMAGE2D:
  2771.         gl_CopyTexSubImage2D( ctx, n[1].e, n[2].i, n[3].i, n[4].i,
  2772.                   n[5].i, n[6].i, n[7].i, n[8].i );
  2773.         break;
  2774.      case OPCODE_COPY_TEX_SUB_IMAGE3D:
  2775.         gl_CopyTexSubImage3DEXT( ctx, n[1].e, n[2].i, n[3].i, n[4].i,
  2776.                      n[5].i, n[6].i, n[7].i, n[8].i , n[9].i);
  2777.         break;
  2778.      case OPCODE_CULL_FACE:
  2779.         gl_CullFace( ctx, n[1].e );
  2780.         break;
  2781.      case OPCODE_DEPTH_FUNC:
  2782.         gl_DepthFunc( ctx, n[1].e );
  2783.         break;
  2784.      case OPCODE_DEPTH_MASK:
  2785.         gl_DepthMask( ctx, n[1].b );
  2786.         break;
  2787.      case OPCODE_DEPTH_RANGE:
  2788.         gl_DepthRange( ctx, (GLclampd) n[1].f, (GLclampd) n[2].f );
  2789.         break;
  2790.      case OPCODE_DISABLE:
  2791.         gl_Disable( ctx, n[1].e );
  2792.         break;
  2793.      case OPCODE_DRAW_BUFFER:
  2794.         gl_DrawBuffer( ctx, n[1].e );
  2795.         break;
  2796.      case OPCODE_DRAW_PIXELS:
  2797.         gl_DrawPixels( ctx, (struct gl_image *) n[1].data );
  2798.         break;
  2799.      case OPCODE_EDGE_FLAG:
  2800.         ctx->Current.EdgeFlag = n[1].b;
  2801.         break;
  2802.      case OPCODE_ENABLE:
  2803.         gl_Enable( ctx, n[1].e );
  2804.         break;
  2805.      case OPCODE_EVALCOORD1:
  2806.         gl_EvalCoord1f( ctx, n[1].f );
  2807.         break;
  2808.      case OPCODE_EVALCOORD2:
  2809.         gl_EvalCoord2f( ctx, n[1].f, n[2].f );
  2810.         break;
  2811.      case OPCODE_EVALMESH1:
  2812.         gl_EvalMesh1( ctx, n[1].e, n[2].i, n[3].i );
  2813.         break;
  2814.      case OPCODE_EVALMESH2:
  2815.         gl_EvalMesh2( ctx, n[1].e, n[2].i, n[3].i, n[4].i, n[5].i );
  2816.         break;
  2817.      case OPCODE_EVALPOINT1:
  2818.         gl_EvalPoint1( ctx, n[1].i );
  2819.         break;
  2820.      case OPCODE_EVALPOINT2:
  2821.         gl_EvalPoint2( ctx, n[1].i, n[2].i );
  2822.         break;
  2823.      case OPCODE_FOG:
  2824.         {
  2825. #if (defined(__STORM__) && defined(__PPC__))
  2826.            g_params[0] = n[2].f;
  2827.            g_params[1] = n[3].f;
  2828.            g_params[2] = n[4].f;
  2829.            g_params[3] = n[5].f;
  2830.            gl_Fogfv( ctx, n[1].e, g_params );
  2831. #else
  2832.            GLfloat p[4];
  2833.            p[0] = n[2].f;
  2834.            p[1] = n[3].f;
  2835.            p[2] = n[4].f;
  2836.            p[3] = n[5].f;
  2837.            gl_Fogfv( ctx, n[1].e, p );
  2838. #endif
  2839.         }
  2840.         break;
  2841.      case OPCODE_FRONT_FACE:
  2842.         gl_FrontFace( ctx, n[1].e );
  2843.         break;
  2844.      case OPCODE_FRUSTUM:
  2845.         gl_Frustum( ctx, n[1].f, n[2].f, n[3].f, n[4].f, n[5].f, n[6].f );
  2846.         break;
  2847.      case OPCODE_HINT:
  2848.         gl_Hint( ctx, n[1].e, n[2].e );
  2849.         break;
  2850.      case OPCODE_INDEX_MASK:
  2851.         gl_IndexMask( ctx, n[1].ui );
  2852.         break;
  2853.      case OPCODE_INIT_NAMES:
  2854.         gl_InitNames( ctx );
  2855.         break;
  2856.      case OPCODE_LIGHT:
  2857.         {
  2858. #if (defined(__STORM__) && defined(__PPC__))
  2859.            g_params[0] = n[2].f;
  2860.            g_params[1] = n[3].f;
  2861.            g_params[2] = n[4].f;
  2862.            g_params[3] = n[5].f;
  2863.            gl_Lightfv( ctx, n[1].e, n[2].e, g_params, 4 );
  2864. #else
  2865.            GLfloat p[4];
  2866.            p[0] = n[3].f;
  2867.            p[1] = n[4].f;
  2868.            p[2] = n[5].f;
  2869.            p[3] = n[6].f;
  2870.            gl_Lightfv( ctx, n[1].e, n[2].e, p, 4 );
  2871. #endif
  2872.         }
  2873.         break;
  2874.      case OPCODE_LIGHT_MODEL:
  2875.         {
  2876. #if (defined(__STORM__) && defined(__PPC__))
  2877.            g_params[0] = n[2].f;
  2878.            g_params[1] = n[3].f;
  2879.            g_params[2] = n[4].f;
  2880.            g_params[3] = n[5].f;
  2881.            gl_LightModelfv( ctx, n[1].e, g_params );
  2882. #else
  2883.            GLfloat p[4];
  2884.            p[0] = n[2].f;
  2885.            p[1] = n[3].f;
  2886.            p[2] = n[4].f;
  2887.            p[3] = n[5].f;
  2888.            gl_LightModelfv( ctx, n[1].e, p );
  2889. #endif
  2890.         }
  2891.         break;
  2892.      case OPCODE_LINE_STIPPLE:
  2893.         gl_LineStipple( ctx, n[1].i, n[2].us );
  2894.         break;
  2895.      case OPCODE_LINE_WIDTH:
  2896.         gl_LineWidth( ctx, n[1].f );
  2897.         break;
  2898.      case OPCODE_LIST_BASE:
  2899.         gl_ListBase( ctx, n[1].ui );
  2900.         break;
  2901.      case OPCODE_LOAD_IDENTITY:
  2902.         gl_LoadIdentity( ctx );
  2903.         break;
  2904.      case OPCODE_LOAD_MATRIX:
  2905.         if (sizeof(Node)==sizeof(GLfloat)) {
  2906.            gl_LoadMatrixf( ctx, &n[1].f );
  2907.         }
  2908.         else {
  2909. #if (defined(__STORM__) && defined(__PPC__))
  2910.            GLuint i;
  2911.            for (i=0;i<16;i++) {
  2912.           g_params[i] = n[1+i].f;
  2913.            }
  2914.            gl_LoadMatrixf( ctx, g_params );
  2915. #else
  2916.            GLfloat m[16];
  2917.            GLuint i;
  2918.            for (i=0;i<16;i++) {
  2919.           m[i] = n[1+i].f;
  2920.            }
  2921.            gl_LoadMatrixf( ctx, m );
  2922. #endif
  2923.         }
  2924.         break;
  2925.      case OPCODE_LOAD_NAME:
  2926.         gl_LoadName( ctx, n[1].ui );
  2927.         break;
  2928.      case OPCODE_LOGIC_OP:
  2929.         gl_LogicOp( ctx, n[1].e );
  2930.         break;
  2931.      case OPCODE_MAP1:
  2932.         gl_Map1f( ctx, n[1].e, n[2].f, n[3].f,
  2933.               n[4].i, n[5].i, (GLfloat *) n[6].data, GL_TRUE );
  2934.         break;
  2935.      case OPCODE_MAP2:
  2936.         gl_Map2f( ctx, n[1].e,
  2937.               n[2].f, n[3].f,  /* u1, u2 */
  2938.               n[6].i, n[8].i,  /* ustride, uorder */
  2939.               n[4].f, n[5].f,  /* v1, v2 */
  2940.               n[7].i, n[9].i,  /* vstride, vorder */
  2941.               (GLfloat *) n[10].data,
  2942.               GL_TRUE);
  2943.         break;
  2944.      case OPCODE_MAPGRID1:
  2945.         gl_MapGrid1f( ctx, n[1].i, n[2].f, n[3].f );
  2946.         break;
  2947.      case OPCODE_MAPGRID2:
  2948.         gl_MapGrid2f( ctx, n[1].i, n[2].f, n[3].f, n[4].i, n[5].f, n[6].f);
  2949.         break;
  2950.      case OPCODE_MATERIAL:
  2951.         {
  2952. #if (defined(__STORM__) && defined(__PPC__))
  2953.            g_params[0] = n[3].f;
  2954.            g_params[1] = n[4].f;
  2955.            g_params[2] = n[5].f;
  2956.            g_params[3] = n[6].f;
  2957.            gl_Materialfv( ctx, n[1].e, n[2].e, g_params );
  2958. #else
  2959.            GLfloat params[4];
  2960.            params[0] = n[3].f;
  2961.            params[1] = n[4].f;
  2962.            params[2] = n[5].f;
  2963.            params[3] = n[6].f;
  2964.            gl_Materialfv( ctx, n[1].e, n[2].e, params );
  2965. #endif
  2966.         }
  2967.         break;
  2968.      case OPCODE_MATRIX_MODE:
  2969.         gl_MatrixMode( ctx, n[1].e );
  2970.         break;
  2971.      case OPCODE_MULT_MATRIX:
  2972.         if (sizeof(Node)==sizeof(GLfloat)) {
  2973.            gl_MultMatrixf( ctx, &n[1].f );
  2974.         }
  2975.         else {
  2976. #if (defined(__STORM__) && defined(__PPC__))
  2977.            GLuint i;
  2978.            for (i=0;i<16;i++) {
  2979.           g_params[i] = n[1+i].f;
  2980.            }
  2981.            gl_MultMatrixf( ctx, g_params );
  2982. #else
  2983.            GLfloat m[16];
  2984.            GLuint i;
  2985.            for (i=0;i<16;i++) {
  2986.           m[i] = n[1+i].f;
  2987.            }
  2988.            gl_MultMatrixf( ctx, m );
  2989. #endif
  2990.         }
  2991.         break;
  2992.      case OPCODE_MULTI_TEXCOORD4:
  2993.         (*ctx->Exec.MultiTexCoord4f)( ctx, n[1].e,
  2994.                       n[2].f, n[3].f, n[4].f, n[5].f );
  2995.         break;
  2996.      case OPCODE_ORTHO:
  2997.         gl_Ortho( ctx, n[1].f, n[2].f, n[3].f, n[4].f, n[5].f, n[6].f );
  2998.         break;
  2999.      case OPCODE_PASSTHROUGH:
  3000.         gl_PassThrough( ctx, n[1].f );
  3001.         break;
  3002.      case OPCODE_PIXEL_MAP:
  3003.         gl_PixelMapfv( ctx, n[1].e, n[2].i, (GLfloat *) n[3].data );
  3004.         break;
  3005.      case OPCODE_PIXEL_TRANSFER:
  3006.         gl_PixelTransferf( ctx, n[1].e, n[2].f );
  3007.         break;
  3008.      case OPCODE_PIXEL_ZOOM:
  3009.         gl_PixelZoom( ctx, n[1].f, n[2].f );
  3010.         break;
  3011.      case OPCODE_POINT_SIZE:
  3012.         gl_PointSize( ctx, n[1].f );
  3013.         break;
  3014.      case OPCODE_POINT_PARAMETERS:
  3015.         {
  3016. #if (defined(__STORM__) && defined(__PPC__))
  3017.         g_params[0] = n[2].f;
  3018.         g_params[1] = n[3].f;
  3019.         g_params[2] = n[4].f;
  3020.         gl_PointParameterfvEXT( ctx, n[1].e, g_params );
  3021. #else
  3022.         GLfloat params[3];
  3023.         params[0] = n[2].f;
  3024.         params[1] = n[3].f;
  3025.         params[2] = n[4].f;
  3026.         gl_PointParameterfvEXT( ctx, n[1].e, params ); 
  3027. #endif
  3028.         }
  3029.         break;
  3030.      case OPCODE_POLYGON_MODE:
  3031.         gl_PolygonMode( ctx, n[1].e, n[2].e );
  3032.         break;
  3033.      case OPCODE_POLYGON_STIPPLE:
  3034.         gl_PolygonStipple( ctx, (GLuint *) n[1].data );
  3035.         break;
  3036.      case OPCODE_POLYGON_OFFSET:
  3037.         gl_PolygonOffset( ctx, n[1].f, n[2].f );
  3038.         break;
  3039.      case OPCODE_POP_ATTRIB:
  3040.         gl_PopAttrib( ctx );
  3041.         break;
  3042.      case OPCODE_POP_MATRIX:
  3043.         gl_PopMatrix( ctx );
  3044.         break;
  3045.      case OPCODE_POP_NAME:
  3046.         gl_PopName( ctx );
  3047.         break;
  3048.      case OPCODE_PRIORITIZE_TEXTURE:
  3049.         gl_PrioritizeTextures( ctx, 1, &n[1].ui, &n[2].f );
  3050.         break;
  3051.      case OPCODE_PUSH_ATTRIB:
  3052.         gl_PushAttrib( ctx, n[1].bf );
  3053.         break;
  3054.      case OPCODE_PUSH_MATRIX:
  3055.         gl_PushMatrix( ctx );
  3056.         break;
  3057.      case OPCODE_PUSH_NAME:
  3058.         gl_PushName( ctx, n[1].ui );
  3059.         break;
  3060.      case OPCODE_RASTER_POS:
  3061.         gl_RasterPos4f( ctx, n[1].f, n[2].f, n[3].f, n[4].f );
  3062.         break;
  3063.      case OPCODE_READ_BUFFER:
  3064.         gl_ReadBuffer( ctx, n[1].e );
  3065.         break;
  3066.      case OPCODE_RECTF:
  3067.         gl_Rectf( ctx, n[1].f, n[2].f, n[3].f, n[4].f );
  3068.         break;
  3069.      case OPCODE_SELECT_TEXTURE:
  3070.         gl_SelectTexture( ctx, n[1].e );
  3071.         break;
  3072.      case OPCODE_SELECT_TEXTURE_SGIS:
  3073.         gl_SelectTextureSGIS( ctx, n[1].e );
  3074.         break;
  3075.      case OPCODE_SELECT_TEXTURE_COORD_SET:
  3076.         gl_SelectTextureCoordSet( ctx, n[1].e );
  3077.         break;
  3078.      case OPCODE_SELECT_TEXTURE_TRANSFORM:
  3079.         gl_SelectTextureTransform( ctx, n[1].e );
  3080.         break;
  3081.      case OPCODE_SCALE:
  3082.         gl_Scalef( ctx, n[1].f, n[2].f, n[3].f );
  3083.         break;
  3084.      case OPCODE_SCISSOR:
  3085.         gl_Scissor( ctx, n[1].i, n[2].i, n[3].i, n[4].i );
  3086.         break;
  3087.      case OPCODE_SHADE_MODEL:
  3088.         gl_ShadeModel( ctx, n[1].e );
  3089.         break;
  3090.      case OPCODE_STENCIL_FUNC:
  3091.         gl_StencilFunc( ctx, n[1].e, n[2].i, n[3].ui );
  3092.         break;
  3093.      case OPCODE_STENCIL_MASK:
  3094.         gl_StencilMask( ctx, n[1].ui );
  3095.         break;
  3096.      case OPCODE_STENCIL_OP:
  3097.         gl_StencilOp( ctx, n[1].e, n[2].e, n[3].e );
  3098.         break;
  3099.      case OPCODE_TEXENV:
  3100.         {
  3101. #if (defined(__STORM__) && defined(__PPC__))
  3102.            g_params[0] = n[3].f;
  3103.            g_params[1] = n[4].f;
  3104.            g_params[2] = n[5].f;
  3105.            g_params[3] = n[6].f;
  3106.            gl_TexEnvfv( ctx, n[1].e, n[2].e, g_params );
  3107. #else
  3108.            GLfloat params[4];
  3109.            params[0] = n[3].f;
  3110.            params[1] = n[4].f;
  3111.            params[2] = n[5].f;
  3112.            params[3] = n[6].f;
  3113.            gl_TexEnvfv( ctx, n[1].e, n[2].e, params );
  3114. #endif
  3115.         }
  3116.         break;
  3117.      case OPCODE_TEXGEN:
  3118.         {
  3119. #if (defined(__STORM__) && defined(__PPC__))
  3120.            g_params[0] = n[3].f;
  3121.            g_params[1] = n[4].f;
  3122.            g_params[2] = n[5].f;
  3123.            g_params[3] = n[6].f;
  3124.            gl_TexGenfv( ctx, n[1].e, n[2].e, g_params );
  3125. #else
  3126.            GLfloat params[4];
  3127.            params[0] = n[3].f;
  3128.            params[1] = n[4].f;
  3129.            params[2] = n[5].f;
  3130.            params[3] = n[6].f;
  3131.            gl_TexGenfv( ctx, n[1].e, n[2].e, params );
  3132. #endif
  3133.         }
  3134.         break;
  3135.      case OPCODE_TEXPARAMETER:
  3136.         {
  3137. #if (defined(__STORM__) && defined(__PPC__))
  3138.            g_params[0] = n[3].f;
  3139.            g_params[1] = n[4].f;
  3140.            g_params[2] = n[5].f;
  3141.            g_params[3] = n[6].f;
  3142.            gl_TexParameterfv( ctx, n[1].e, n[2].e, g_params );
  3143. #else
  3144.            GLfloat params[4];
  3145.            params[0] = n[3].f;
  3146.            params[1] = n[4].f;
  3147.            params[2] = n[5].f;
  3148.            params[3] = n[6].f;
  3149.            gl_TexParameterfv( ctx, n[1].e, n[2].e, params );
  3150. #endif
  3151.         }
  3152.         break;
  3153.      case OPCODE_TEX_IMAGE1D:
  3154.         gl_TexImage1D( ctx,
  3155.                n[1].e, /* target */
  3156.                n[2].i, /* level */
  3157.                n[3].i, /* components */
  3158.                n[4].i, /* width */
  3159.                n[5].e, /* border */
  3160.                n[6].e, /* format */
  3161.                n[7].e, /* type */
  3162.                (struct gl_image *) n[8].data );
  3163.         break;
  3164.      case OPCODE_TEX_IMAGE2D:
  3165.         gl_TexImage2D( ctx,
  3166.                n[1].e, /* target */
  3167.                n[2].i, /* level */
  3168.                n[3].i, /* components */
  3169.                n[4].i, /* width */
  3170.                n[5].i, /* height */
  3171.                n[6].e, /* border */
  3172.                n[7].e, /* format */
  3173.                n[8].e, /* type */
  3174.                (struct gl_image *) n[9].data );
  3175.         break;
  3176.      case OPCODE_TEX_IMAGE3D:
  3177.         gl_TexImage3DEXT( ctx,
  3178.                   n[1].e, /* target */
  3179.                   n[2].i, /* level */
  3180.                   n[3].i, /* components */
  3181.                   n[4].i, /* width */
  3182.                   n[5].i, /* height */
  3183.                   n[6].i, /* depth  */
  3184.                   n[7].e, /* border */
  3185.                   n[8].e, /* format */
  3186.                   n[9].e, /* type */
  3187.                   (struct gl_image *) n[10].data );
  3188.         break;
  3189.      case OPCODE_TEX_SUB_IMAGE1D:
  3190.         gl_TexSubImage1D( ctx, n[1].e, n[2].i, n[3].i, n[4].i, n[5].e,
  3191.                   n[6].e, (struct gl_image *) n[7].data );
  3192.         break;
  3193.      case OPCODE_TEX_SUB_IMAGE2D:
  3194.         gl_TexSubImage2D( ctx, n[1].e, n[2].i, n[3].i, n[4].i, n[5].e,
  3195.                   n[6].i, n[7].e, n[8].e,
  3196.                   (struct gl_image *) n[9].data );
  3197.         break;
  3198.      case OPCODE_TEX_SUB_IMAGE3D:
  3199.         gl_TexSubImage3DEXT( ctx, n[1].e, n[2].i, n[3].i, n[4].i, n[5].i,
  3200.                  n[6].i, n[7].i, n[8].i, n[9].e, n[10].e,
  3201.                  (struct gl_image *) n[11].data );
  3202.         break;
  3203.      case OPCODE_TRANSLATE:
  3204.         gl_Translatef( ctx, n[1].f, n[2].f, n[3].f );
  3205.         break;
  3206.      case OPCODE_VIEWPORT:
  3207.         gl_Viewport( ctx,
  3208.              n[1].i, n[2].i, (GLsizei) n[3].i, (GLsizei) n[4].i );
  3209.         break;
  3210.      case OPCODE_WINDOW_POS:
  3211.         gl_WindowPos4fMESA( ctx, n[1].f, n[2].f, n[3].f, n[4].f );
  3212.         break;
  3213.      case OPCODE_CONTINUE:
  3214.         n = (Node *) n[1].next;
  3215.         break;
  3216.      case OPCODE_END_OF_LIST:
  3217.         done = GL_TRUE;
  3218.         break;
  3219.      default:
  3220.         {
  3221.            char msg[1000];
  3222.            sprintf(msg, "Error in execute_list: opcode=%d", (int) opcode);
  3223.            gl_problem( ctx, msg );
  3224.         }
  3225.         done = GL_TRUE;
  3226.       }
  3227. #ifdef AMIGA
  3228.       }
  3229. #endif
  3230.       /* increment n to point to next compiled command */
  3231.       if (opcode!=OPCODE_CONTINUE) {
  3232.      n += InstSize[opcode];
  3233.       }
  3234.  
  3235.    }
  3236.    ctx->CallDepth--;
  3237. }
  3238.  
  3239.  
  3240.  
  3241. /**********************************************************************/
  3242. /*                           GL functions                             */
  3243. /**********************************************************************/
  3244.  
  3245.  
  3246.  
  3247. /*
  3248.  * Test if a display list number is valid.
  3249.  */
  3250. GLboolean gl_IsList( GLcontext *ctx, GLuint list )
  3251. {
  3252.    if (list > 0 && HashLookup(ctx->Shared->DisplayList, list)) {
  3253.       return GL_TRUE;
  3254.    }
  3255.    else {
  3256.       return GL_FALSE;
  3257.    }
  3258. }
  3259.  
  3260.  
  3261.  
  3262. /*
  3263.  * Delete a sequence of consecutive display lists.
  3264.  */
  3265. void gl_DeleteLists( GLcontext *ctx, GLuint list, GLsizei range )
  3266. {
  3267.    GLuint i;
  3268.  
  3269.    if (INSIDE_BEGIN_END(ctx)) {
  3270.       gl_error( ctx, GL_INVALID_OPERATION, "glDeleteLists" );
  3271.       return;
  3272.    }
  3273.    if (range<0) {
  3274.       gl_error( ctx, GL_INVALID_VALUE, "glDeleteLists" );
  3275.       return;
  3276.    }
  3277.    for (i=list;i<list+range;i++) {
  3278.       gl_destroy_list( ctx, i );
  3279.    }
  3280. }
  3281.  
  3282.  
  3283.  
  3284. /*
  3285.  * Return a display list number, n, such that lists n through n+range-1
  3286.  * are free.
  3287.  */
  3288. GLuint gl_GenLists( GLcontext *ctx, GLsizei range )
  3289. {
  3290.    GLuint base;
  3291.  
  3292.    if (INSIDE_BEGIN_END(ctx)) {
  3293.       gl_error( ctx, GL_INVALID_OPERATION, "glGenLists" );
  3294.       return 0;
  3295.    }
  3296.    if (range<0) {
  3297.       gl_error( ctx, GL_INVALID_VALUE, "glGenLists" );
  3298.       return 0;
  3299.    }
  3300.    if (range==0) {
  3301.       return 0;
  3302.    }
  3303.  
  3304.    base = HashFindFreeKeyBlock(ctx->Shared->DisplayList, range);
  3305.    if (base) {
  3306.       /* reserve the list IDs by with empty/dummy lists */
  3307.       GLint i;
  3308.       for (i=0; i<range; i++) {
  3309.      HashInsert(ctx->Shared->DisplayList, base+i, make_empty_list());
  3310.       }
  3311.    }
  3312.    return base;
  3313. }
  3314.  
  3315.  
  3316.  
  3317. /*
  3318.  * Begin a new display list.
  3319.  */
  3320. void gl_NewList( GLcontext *ctx, GLuint list, GLenum mode )
  3321. {
  3322.    if (INSIDE_BEGIN_END(ctx)) {
  3323.       gl_error( ctx, GL_INVALID_OPERATION, "glNewList" );
  3324.       return;
  3325.    }
  3326.    if (list==0) {
  3327.       gl_error( ctx, GL_INVALID_VALUE, "glNewList" );
  3328.       return;
  3329.    }
  3330.    if (mode!=GL_COMPILE && mode!=GL_COMPILE_AND_EXECUTE) {
  3331.       gl_error( ctx, GL_INVALID_ENUM, "glNewList" );
  3332.       return;
  3333.    }
  3334.    if (ctx->CurrentListPtr) {
  3335.       /* already compiling a display list */
  3336.       gl_error( ctx, GL_INVALID_OPERATION, "glNewList" );
  3337.       return;
  3338.    }
  3339.  
  3340.    /* Allocate new display list */
  3341.    ctx->CurrentListNum = list;
  3342.    ctx->CurrentListPtr = ctx->CurrentBlock = (Node *) malloc( sizeof(Node) * BLOCK_SIZE );
  3343.    ctx->CurrentPos = 0;
  3344.  
  3345.    ctx->CompileFlag = GL_TRUE;
  3346.    if (mode==GL_COMPILE) {
  3347.       ctx->ExecuteFlag = GL_FALSE;
  3348.    }
  3349.    else {
  3350.       /* Compile and execute */
  3351.       ctx->ExecuteFlag = GL_TRUE;
  3352.    }
  3353.  
  3354.    ctx->API = ctx->Save;  /* Switch the API function pointers */
  3355. }
  3356.  
  3357.  
  3358.  
  3359. /*
  3360.  * End definition of current display list.
  3361.  */
  3362. void gl_EndList( GLcontext *ctx )
  3363. {
  3364.    /* Check that a list is under construction */
  3365.    if (!ctx->CurrentListPtr) {
  3366.       gl_error( ctx, GL_INVALID_OPERATION, "glEndList" );
  3367.       return;
  3368.    }
  3369.  
  3370.    (void) alloc_instruction( ctx, OPCODE_END_OF_LIST, 0 );
  3371.  
  3372.    /* Destroy old list, if any */
  3373.    gl_destroy_list(ctx, ctx->CurrentListNum);
  3374.    /* Install the list */
  3375.    HashInsert(ctx->Shared->DisplayList, ctx->CurrentListNum, ctx->CurrentListPtr);
  3376.  
  3377.    ctx->CurrentListNum = 0;
  3378.    ctx->CurrentListPtr = NULL;
  3379.    ctx->ExecuteFlag = GL_TRUE;
  3380.    ctx->CompileFlag = GL_FALSE;
  3381.  
  3382.    ctx->API = ctx->Exec;   /* Switch the API function pointers */
  3383. }
  3384.  
  3385.  
  3386.  
  3387. void gl_CallList( GLcontext *ctx, GLuint list )
  3388. {
  3389.    /* VERY IMPORTANT:  Save the CompileFlag status, turn it off, */
  3390.    /* execute the display list, and restore the CompileFlag. */
  3391.    GLboolean save_compile_flag;
  3392.    save_compile_flag = ctx->CompileFlag;
  3393.    ctx->CompileFlag = GL_FALSE;
  3394.    execute_list( ctx, list );
  3395.    ctx->CompileFlag = save_compile_flag;
  3396.  
  3397.    /* also restore API function pointers to point to "save" versions */
  3398.    if (save_compile_flag)
  3399.        ctx->API = ctx->Save;
  3400. }
  3401.  
  3402.  
  3403.  
  3404. /*
  3405.  * Execute glCallLists:  call multiple display lists.
  3406.  */
  3407. void gl_CallLists( GLcontext *ctx,
  3408.            GLsizei n, GLenum type, const GLvoid *lists )
  3409. {
  3410.    GLuint list;
  3411.    GLint i;
  3412.    GLboolean save_compile_flag;
  3413.  
  3414.    /* Save the CompileFlag status, turn it off, execute display list,
  3415.     * and restore the CompileFlag.
  3416.     */
  3417.    save_compile_flag = ctx->CompileFlag;
  3418.    ctx->CompileFlag = GL_FALSE;
  3419.  
  3420.    for (i=0;i<n;i++) {
  3421.       list = translate_id( i, type, lists );
  3422.       execute_list( ctx, ctx->List.ListBase + list );
  3423.    }
  3424.  
  3425.    ctx->CompileFlag = save_compile_flag;
  3426.  
  3427.    /* also restore API function pointers to point to "save" versions */
  3428.    if (save_compile_flag)
  3429.        ctx->API = ctx->Save;
  3430. }
  3431.  
  3432.  
  3433.  
  3434. /*
  3435.  * Set the offset added to list numbers in glCallLists.
  3436.  */
  3437. void gl_ListBase( GLcontext *ctx, GLuint base )
  3438. {
  3439.    if (INSIDE_BEGIN_END(ctx)) {
  3440.       gl_error( ctx, GL_INVALID_OPERATION, "glListBase" );
  3441.       return;
  3442.    }
  3443.    ctx->List.ListBase = base;
  3444. }
  3445.  
  3446.  
  3447.  
  3448. #ifndef AMIGA
  3449. /***
  3450.  *** Debugging code
  3451.  ***/
  3452.  
  3453. static char tmp[1000];
  3454.  
  3455. static char *enum_string( GLenum k )
  3456. {
  3457.    /* TODO: Add many more constant/string entries */
  3458.    switch (k) {
  3459.       case GL_POINTS:           return "GL_POINTS";
  3460.       case GL_LINES:            return "GL_LINES";
  3461.       case GL_LINE_STRIP:       return "GL_LINE_STRIP";
  3462.       case GL_LINE_LOOP:        return "GL_LINE_LOOP";
  3463.       case GL_TRIANGLES:        return "GL_TRIANGLES";
  3464.       case GL_TRIANGLE_STRIP:   return "GL_TRIANGLE_STRIP";
  3465.       case GL_TRIANGLE_FAN:     return "GL_TRIANGLE_FAN";
  3466.       case GL_QUADS:            return "GL_QUADS";
  3467.       case GL_QUAD_STRIP:       return "GL_QUAD_STRIP";
  3468.       case GL_POLYGON:          return "GL_POLYGON";
  3469.       case GL_FRONT:            return "GL_FRONT";
  3470.       case GL_BACK:             return "GL_BACK";
  3471.       case GL_FRONT_AND_BACK:   return "GL_FRONT_AND_BACK";
  3472.       case GL_AMBIENT:          return "GL_AMBIENT";
  3473.       case GL_DIFFUSE:          return "GL_DIFFUSE";
  3474.       case GL_SPECULAR:         return "GL_SPECULAR";
  3475.       case GL_SHININESS:        return "GL_SHININESS";
  3476.       default:
  3477.      sprintf(tmp,"0x%X", k);
  3478.      return tmp;
  3479.    }
  3480. }
  3481.  
  3482.  
  3483. /*
  3484.  * Print the commands in a display list.  For debugging only.
  3485.  * TODO: many commands aren't handled yet.
  3486.  */
  3487. static void print_list( GLcontext *ctx, FILE *f, GLuint list )
  3488. {
  3489.    Node *n;
  3490.    GLboolean done;
  3491.    OpCode opcode;
  3492.  
  3493.    if (!glIsList(list)) {
  3494.       fprintf(f,"%d is not a display list ID\n",list);
  3495.       return;
  3496.    }
  3497.  
  3498.    n = (Node *) HashLookup(ctx->Shared->DisplayList, list);
  3499.  
  3500.    fprintf( f, "START-LIST %d, address %p\n", list, (void*)n );
  3501.  
  3502.    done = n ? GL_FALSE : GL_TRUE;
  3503.    while (!done) {
  3504.       opcode = n[0].opcode;
  3505.  
  3506.       switch (opcode) {
  3507.      case OPCODE_ACCUM:
  3508.         fprintf(f,"accum %d %g\n", n[1].e, n[2].f );
  3509.         break;
  3510.      case OPCODE_BEGIN:
  3511.         fprintf(f,"Begin %s\n", enum_string(n[1].e) );
  3512.         break;
  3513.      case OPCODE_BITMAP:
  3514.         fprintf(f,"Bitmap %d %d %g %g %g %g %p\n", n[1].i, n[2].i,
  3515.                n[3].f, n[4].f, n[5].f, n[6].f, (void *) n[7].data );
  3516.         break;
  3517.      case OPCODE_CALL_LIST:
  3518.         fprintf(f,"CallList %d\n", (int) n[1].ui );
  3519.         break;
  3520.      case OPCODE_CALL_LIST_OFFSET:
  3521.         fprintf(f,"CallList %d + offset %d = %d\n", (int) n[1].ui,
  3522.             ctx->List.ListBase, ctx->List.ListBase + n[1].ui );
  3523.         break;
  3524.      case OPCODE_COLOR_3F:
  3525.         fprintf(f,"Color3f %g %g %gn", n[1].f, n[2].f, n[3].f );
  3526.         break;
  3527.      case OPCODE_COLOR_4F:
  3528.         fprintf(f,"Color4f %g %g %g %g\n", n[1].f, n[2].f, n[3].f, n[4].f);
  3529.         break;
  3530.      case OPCODE_COLOR_4UB:
  3531.         fprintf(f,"Color4ub %d %d %d %d\n", n[1].ub, n[2].ub,
  3532.                         n[3].ub, n[4].ub );
  3533.         break;
  3534.      case OPCODE_DISABLE:
  3535.         fprintf(f,"Disable %s\n", enum_string(n[1].e));
  3536.         break;
  3537.      case OPCODE_ENABLE:
  3538.         fprintf(f,"Enable %s\n", enum_string(n[1].e));
  3539.         break;
  3540.      case OPCODE_END:
  3541.         fprintf(f,"End\n");
  3542.         break;
  3543.      case OPCODE_FRUSTUM:
  3544.         fprintf(f,"Frustum %g %g %g %g %g %g\n",
  3545.             n[1].f, n[2].f, n[3].f, n[4].f, n[5].f, n[6].f );
  3546.         break;
  3547.      case OPCODE_INDEX:
  3548.         fprintf(f,"Index %d\n", (int) n[1].ui );
  3549.         break;
  3550.      case OPCODE_LINE_STIPPLE:
  3551.         fprintf(f,"LineStipple %d %x\n", n[1].i, (int) n[2].us );
  3552.         break;
  3553.      case OPCODE_LOAD_IDENTITY:
  3554.         fprintf(f,"LoadIdentity\n");
  3555.         break;
  3556.      case OPCODE_LOAD_MATRIX:
  3557.         fprintf(f,"LoadMatrix\n");
  3558.         fprintf(f,"  %8f %8f %8f %8f\n", n[1].f, n[5].f,  n[9].f, n[13].f);
  3559.         fprintf(f,"  %8f %8f %8f %8f\n", n[2].f, n[6].f, n[10].f, n[14].f);
  3560.         fprintf(f,"  %8f %8f %8f %8f\n", n[3].f, n[7].f, n[11].f, n[15].f);
  3561.         fprintf(f,"  %8f %8f %8f %8f\n", n[4].f, n[8].f, n[12].f, n[16].f);
  3562.         break;
  3563.      case OPCODE_MATERIAL:
  3564.         fprintf(f,"Material %s %s %g %g %g %g\n", enum_string(n[1].e),
  3565.             enum_string(n[2].e), n[3].f, n[4].f, n[5].f, n[6].f );
  3566.         break;
  3567.      case OPCODE_MULT_MATRIX:
  3568.         fprintf(f,"MultMatrix (or Rotate)\n");
  3569.         fprintf(f,"  %8f %8f %8f %8f\n", n[1].f, n[5].f,  n[9].f, n[13].f);
  3570.         fprintf(f,"  %8f %8f %8f %8f\n", n[2].f, n[6].f, n[10].f, n[14].f);
  3571.         fprintf(f,"  %8f %8f %8f %8f\n", n[3].f, n[7].f, n[11].f, n[15].f);
  3572.         fprintf(f,"  %8f %8f %8f %8f\n", n[4].f, n[8].f, n[12].f, n[16].f);
  3573.         break;
  3574.      case OPCODE_NORMAL:
  3575.         fprintf(f,"Normal %g %g %g\n", n[1].f, n[2].f, n[3].f );
  3576.         break;
  3577.      case OPCODE_ORTHO:
  3578.         fprintf(f,"Ortho %g %g %g %g %g %g\n",
  3579.             n[1].f, n[2].f, n[3].f, n[4].f, n[5].f, n[6].f );
  3580.         break;
  3581.      case OPCODE_POP_ATTRIB:
  3582.         fprintf(f,"PopAttrib\n");
  3583.         break;
  3584.      case OPCODE_POP_MATRIX:
  3585.         fprintf(f,"PopMatrix\n");
  3586.         break;
  3587.      case OPCODE_POP_NAME:
  3588.         fprintf(f,"PopName\n");
  3589.         break;
  3590.      case OPCODE_PUSH_ATTRIB:
  3591.         fprintf(f,"PushAttrib %x\n", n[1].bf );
  3592.         break;
  3593.      case OPCODE_PUSH_MATRIX:
  3594.         fprintf(f,"PushMatrix\n");
  3595.         break;
  3596.      case OPCODE_PUSH_NAME:
  3597.         fprintf(f,"PushName %d\n", (int) n[1].ui );
  3598.         break;
  3599.      case OPCODE_RASTER_POS:
  3600.         fprintf(f,"RasterPos %g %g %g %g\n", n[1].f, n[2].f,n[3].f,n[4].f);
  3601.         break;
  3602.      case OPCODE_RECTF:
  3603.         fprintf( f, "Rectf %g %g %g %g\n", n[1].f, n[2].f, n[3].f, n[4].f);
  3604.         break;
  3605.      case OPCODE_SCALE:
  3606.         fprintf(f,"Scale %g %g %g\n", n[1].f, n[2].f, n[3].f );
  3607.         break;
  3608.      case OPCODE_TEXCOORD2:
  3609.         fprintf(f,"TexCoord %g %g\n", n[1].f, n[2].f);
  3610.         break;
  3611.      case OPCODE_TEXCOORD4:
  3612.         fprintf(f,"TexCoord %g %g %g %g\n", n[1].f, n[2].f, n[3].f,n[4].f);
  3613.         break;
  3614.      case OPCODE_TRANSLATE:
  3615.         fprintf(f,"Translate %g %g %g\n", n[1].f, n[2].f, n[3].f );
  3616.         break;
  3617.      case OPCODE_VERTEX2:
  3618.         fprintf(f,"Vertex %g %g\n", n[1].f, n[2].f );
  3619.         break;
  3620.      case OPCODE_VERTEX3:
  3621.         fprintf(f,"Vertex %g %g %g\n", n[1].f, n[2].f, n[3].f );
  3622.         break;
  3623.      case OPCODE_VERTEX4:
  3624.         fprintf(f,"Vertex %g %g %g %g\n", n[1].f, n[2].f, n[3].f, n[4].f );
  3625.         break;
  3626.  
  3627.      /*
  3628.       * meta opcodes/commands
  3629.       */
  3630.      case OPCODE_CONTINUE:
  3631.         fprintf(f,"DISPLAY-LIST-CONTINUE\n");
  3632.         n = (Node *) n[1].next;
  3633.         break;
  3634.      case OPCODE_END_OF_LIST:
  3635.         fprintf(f,"END-LIST %d\n", list);
  3636.         done = GL_TRUE;
  3637.         break;
  3638.      default:
  3639.         if (opcode < 0 || opcode > OPCODE_END_OF_LIST) {
  3640.            fprintf(f,"ERROR IN DISPLAY LIST: opcode = %d, address = %p\n",
  3641.                opcode, (void*) n);
  3642.            return;
  3643.         }
  3644.         else {
  3645.            fprintf(f,"command %d, %d operands\n",opcode,InstSize[opcode]);
  3646.         }
  3647.       }
  3648.  
  3649.       /* increment n to point to next compiled command */
  3650.       if (opcode!=OPCODE_CONTINUE) {
  3651.      n += InstSize[opcode];
  3652.       }
  3653.  
  3654.    }
  3655. }
  3656.  
  3657.  
  3658.  
  3659. /*
  3660.  * Clients may call this function to help debug display list problems.
  3661.  * This function is _ONLY_FOR_DEBUGGING_PURPOSES_.  It may be removed,
  3662.  * changed, or break in the future without notice.
  3663.  */
  3664. void mesa_print_display_list( GLuint list )
  3665. {
  3666.    GLcontext *ctx;
  3667. #ifdef THREADS
  3668.    ctx = gl_get_thread_context();
  3669. #else
  3670.    ctx = CC;
  3671. #endif
  3672.    print_list( ctx, stdout, list );
  3673. }
  3674. #endif
  3675.